JavaScript language: Comment

a comment is used for understanding JavaScript code. you can place comments in code that are not executed as part of the program.

there are two ways, you can declare a comment in JavaScript single-line comment and multi-line comment.

Single-Line comments

Any line starting with a double slash \\ is Single-Line comments. for example

// javascript program to print 1 to 10
for(i=1;i<=10;i++)
{
   document.writeln(i);
}

Here, // javascript program to print 1 to 10 is a comment


Multi-Line comments

In JavaScript, multi-line comments start with /* and end with */

Any text between /* and */ is a multi-line comment. For example,

/* it will print 1 to 10
for loop start with 1 and end with 10
and increment by 1 */
for(i=1;i<=10;i++)
{
   document.writeln(i);
}