JavaScript Comments

Last Updated Jul 29, 2015, 07:00:14 PM





JavaScript Comments

Comments are used to explain what exactly the program does?. Comments explain what exactly a specific function or line of code does. JavaScript comments are also the same. Comments are ignored by the program so that it won't get executed.

JavaScript comments can also be used to prevent execution, when testing alternative code.

Single Line Comments

Single line comments in JavaScript start with //.

Any text between // and the end of the line, will be ignored by JavaScript (will not be executed).

Syntax Example

In the first two lines of code, we have two comments. Those two comments won't get printed in the program. Check this out with live example

Try It Now

Multi-line Comments

Multi-line comments start with /* and end with */.

Any text between /* and */ will be ignored by JavaScript.

Syntax Example Try It Now


Sources and Credits

The source of the content has been referred and updated with Mozilla Developer Network and W3C Organization

Last Updated Jul 29, 2015, 07:00:14 PM