Wednesday 11 December 2013

Javascript : Understanding Syntax

Javascript (JS):
-> Should be written inside <script> tag
   <script>
   ...........code here.......
   </script>
-> can be added anywhere in the webpage but preferred to be inside <head> tag
   <html>
   <head>
   <script> ... code here ... </script>  
   </head>
   </html>
   this is done because the script will load before the html loads if not it might throw errors
   also help to improve performance of webpage
-> <script language="javascript" type="text/javascript">
    ... code here.....
   </script>
               NOTE : language specify what scripting language are we using.
                            type specify the language should be written in which format.
-> Javascript ignores white spaces and Line breaks.
-> Javascript is provide raw code writing feature as semicolon is optional
     but for the good practices everyone should specify semicolon
-> Javascript is Case-sensitive
     EX : data , Data , DATA ... are different .
-> You can comment Javascript code
   // - for single line
   /* ...multiple line...
    .....code... */

No comments:

Post a Comment