By | August 1, 2013
We all know About JavaScript:
     ·   Object Based Scripted Language
     ·   Light Weight programming Language with less Complexity
     ·   Most commonly used Language to add Dynamism and interactivity
     ·   Client and Server Side object based Scripted Language
And many more things.

Formally JavaScript was known as LiveScript, and developed by NetScape and Sun Microsystem. It is also known as ECMAScript as it was standardized by  “European Computer Manufacture’s Association” .
Now Let’s talk about the Key Features of JavaScript :

1.     Dynamic Text:  This means that the type of variable is defined according to the value stored in it.  For Example: After declaring a variable x, we can assign it a number or string value. This is known as dynamic typing. JavaScript is an object based Scripting language, which provides some built-in objects, such an String, Math and Data objects.

2.     Functional:  It implies that JavaScript does not support ‘classes’. Instead of using classes , objects are created from the constructor  function. Each constructor function represents a unique object type.

3.     Prototype-based:  Implies that JavaScript is a prototype-based language. This means that JavaScript uses prototype instead of classes for inheritance. In JavaScript, each constructor function is associated with a prototype object. There are several built-in objects that represents constructor functions such as
·        Array()
·        Boolean()
·        Data()
·        Error()
·        Math()
·        Number()
·        Number()
·        Object()
·        RegExp()
·        String()
4.      Imperative and structured:  Implies that JavaScript supports all the Syntaxes of the structured programming language ‘C’, such as ‘If’ statement, ‘Loop’ and ‘Switch’ statements. The Only difference between C and JavaScript is that in JavaScript semicolon is not necessary to terminate the statement whereas in C semicolon is necessary to terminate the statement.

5.      Platform Independent:  Implies that JavaScript supports platform-independency or we can Say Portability. We can write our JavaScript application and run it on any platform or any browser without affecting the Output of the script.

JavaScript in HTML Document, Using <SCRIPT> Element:

For this we can follow three ways, which are given below:

1.      JavaScript in HEAD Element
2.      JavaScript in BODY Element
3.      As an External Script File
     
JavaScript in HEAD Element:  We can use JavaScript in HEAD section by given Method. The script placed inside the HEAD element runs when you perform some action, such as click a link or the submit button.
Code Syntax:
<HEAD>
<SCRIPT type=”text/javascript”>
Script code here
</SCRIPT>
</HEAD>
JavaScript in BODY Element:  We can use JavaScript in BODY section by given Method. The script placed inside the BODY element runs when a web page start loading ia a web browser.
Code Syntax:
<BODY>
<SCRIPT type=”text/javascript”>
Script code here
</SCRIPT>
</BODY>
JavaScript as an EXTERNAL Script File:  When JavaScript code created in an HTML file is very lengthy; It affects the readability of the HTML file. In addition, at times we may need to use the same JavaScript code in several Web pages. In such cases, we can store the JavaScript code in an External file and save that file using the ‘.js’ extension. Next we need to link the external file with the HTML document by using ‘src’ attribute of the SCRIPT element to access the script file.
Code Syntax:
<HEAD>
<SCRIPT src=URL of the External .js file>
Script code here
</SCRIPT>
</HEAD>

Leave a Reply

Your email address will not be published. Required fields are marked *