javaScript Comments

the java-script comments can be used to make the code more readable.

the comments is simply text that is ignored by the javascript parser.
or

the comments code will not be executed by javascript.commenting also makes code easier for you to understand.

the javascript support two types of comment

  • single-line comment        // comment -code
  • multiline-line comment     /* ....comment code */

javaScript singleline comments

javascript singleline comments begins with a double foreslash (//).

if single-line comments are used, the parser ignores any text between the comment marker(//) and the end of the line.

example:

 <script>

  var   count =10 ;  //ten number of items count hols
                     
  var   name   ="javascript single line comments" ;  //name hold string type value
                     
       document.write("the count value____"+count);
       
       document.write("<br/>"+"the name value_____"+name);  
        
  </script>                         

javaScript Multiline comments

javascript multiline comments start with /*    and ends with    */ .

if multi-line comments are used, the javascript interpreter ignores any text between the beginning(/*) and end markers(*/).

example:

 <script>
 
 /* the function max  return a max value using the return statement .
                             
in the javascript function declare using the function keyword with name of function                              
                             
                              
 */  
 
     function  max (){
     
                              var   a = 40; var b =50 ;
                              
                              return  b ;   } 
  
  var   count =10;  //this is the single line comment
                     
  var   name   ="javascript multiline comments";  //the name hold the string type value 
                     
       document.write("the count value____"+count);
       
       document.write("<br/>"+"the name value_____"+name);  
        
  </script>                         

note:the multiline comments cannot be nested.

          /* the data value    /*  multiline  nested code */    this is code block */

note:for security and performance sake, you may wish to remove comments from your script before it is delivered to end users on the web.