How to use JavaScript comments?

    Comment is the code or text you wish to have the JavaScript interpreter ignore.
    When you place the code or text between two slashes that text or code will be ignored, until the next line.
    Two types of comments are there:- SingleLine and MultiLine Comments 

SingleLine Comments

    • Single line comments start with //.
    • Any text between // and the end of the line will be ignored by JavaScript (will not be executed).

MultiLine Comments

    • MultiLine line comments start with /*.
    • Any text between /*and*/ the end of the line will be ignored by JavaScript (will not be executed).





Code:-


<!DOCTYPE html> 
<html> 
 
<head> 
 <meta name="viewport" content="width=device-width, initial-scale=1"> 
</head> 
 
<body> 
 
 <h1>Javascript Comments</h1> 
 
 <p id="ans"></p> 
 <input type="button" onclick="get_ans();" value="Answer"> 
 <script> 
  function get_ans() 
  { 
   /*a is the variable also this line will not execute*/ 
   var a = 53; 
   //a=0; 
   document.getElementById("ans").innerHTML = a; 
  } 
 </script> 
 
</body> 
 
</html>

How to use JavaScript comments? How to use JavaScript comments? Reviewed by Network security on June 01, 2019 Rating: 5

No comments:

Useful Information

Powered by Blogger.