JavaScript Comments
JavaScript comments help explain code, making it easier to understand. You can also use them to temporarily disable parts of your code. The JavaScript compiler ignores comments when running the code.
Single Line Comments
Single line comments start with //.
Any text the after // of the line will be ignored by JavaScript (will not be executed).
Example
// Change heading:
document.getElementById("myH").innerHTML = "My First Page";
// Change paragraph:
document.getElementById("myP").innerHTML = "My first paragraph.";
Multi-line Comments
Multi-line comments start with /* and end with */.
Any text between /* and */ will be ignored by JavaScript.
Example
/*
The code below will change
the heading with id = "myH"
and the paragraph with id = "myP"
in my web page:
*/
document.getElementById("myH").innerHTML = "My First Page";
document.getElementById("myP").innerHTML = "My first paragraph.";