Using comments to prevent code execution is useful for testing purposes.
By adding //
at the beginning of a code line, that line is converted from executable code to a comment.
The following example demonstrates how to use //
to disable one of the code lines:
//document.getElementById(“myH”).innerHTML = “My First Page”; document.getElementById(“myP”).innerHTML = “My first paragraph.”; |
This example employs a comment block to disable the execution of multiple lines:
/* document.getElementById(“myH”).innerHTML = “My First Page”; document.getElementById(“myP”).innerHTML = “My first paragraph.”; */ |