IT Questions and Answers :)

Thursday, July 4, 2019

How do you add a single-line comment in JavaScript?

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 
 
How do you add a single-line comment in JavaScript?

 

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.";
 
Share:

0 comments:

Post a Comment

Popular Posts