How do you add a single-line comment in JavaScript?
- 'This is a comment
- <!--This is a comment-->
- #This is a comment
- //This is a comment
EXPLANATION
Single Line Comments
Single line comments start with//
.Any text between
//
and the end of the line will be ignored by JavaScript
(will not be executed).This example uses a single-line comment before each code line:
Example
// Change heading: document.getElementById("myH").innerHTML = "My First Page";// Change paragraph: document.getElementById("myP").innerHTML = "My first paragraph.";
0 comments:
Post a Comment