When Programming, it is good to write the comments around the code so that you know what it is doing and so people reading your code knows what it is doing.
When you add single line comment in JavaScript then start with //.
This example uses single line comments to explain the code:
<script language="javascript"> //single line Comment document.write("This is JavaScript"); document.write("HELLO"); //this will write HELLO </script> |
JavaScript Multi-line Comments
If you want to add Multi line comments in your JvaSript code then start with /* and end with */.
Example on Multi line comment :
<script language="javascript"> /* The code below will write one header and two paragraphs */ document.write("<h1>This is a header</h1>"); document.write("<p>This is a paragraph</p>"); document.write("<p>This is another paragraph</p>"); </script> |