android-logo

JavaScript Comments


JavaScript comments provide meaningful ways to communicate messages. JavaScript comments have the benefit of making code easier to understand. It can be used to explain the code so that the end user can understand it.

In JavaScript, there are two types of comments.

  • Single-line Comment
  • Multi-line Comment

Single-line Comment

We use // for Single-line Comment.

Anything after // will be ignored by JavaScript on that line.

Lets take a look at an example of a single-line comment.


// This is an example of single line comment
document.write("Hello World");  


Multi-line Comment

Anything between /* and */ will be ignored.

It starts with /* and ends with */


/* This is an example of Multi line comment
Below code will print "Hello World" */

document.write("Hello World");  


previous-button
next-button

facebook-logo
twitter-logo
instagram-logo

2020 © All rights reserved.