JavaScript comments can be used to make the code more readable.
Comments can be added to explain the JavaScript, or to make it more readable.
Single line comments start with //.
This example uses single line comments to explain the code:
<script type="text/javascript">
// This will write a header:
document.write("<h1>This is a header</h1>");
// This will write two paragraphs:
document.write("<p>This is a paragraph</p>");
document.write("<p>This is another paragraph</p>");
</script>
In this example the comment is used to prevent the execution of a single code line:
<script type="text/javascript">
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>