JavaScript Comments

JavaScript supports comments like c, c++, java use of comments make the program simple and easy to understand.

There are two different types of comments.

Single line comments:- These comments do not exceed the length of a line. They must start and end on the same line of the source. These comments begin with double-slash (//).

// This is a single line comments…

Multiple line comments:- These comments may exceed the length of one line. They require a sign that marks the beginning of the command and the end of the comment. The opening part is /* and the closing part is */.


/* This is a also a commment.
It contains multiple line */

In addition to // and /…./, client side JavaScript recognizes the HTML comment open sequence <!—-. JavaScript treats this as single line comment just as it does the // comment.

Leave a Reply