Javascript comment

tutorial and example
tutorial and example

JavaScript comments are used to explain JavaScript code. It is used to add information about the code, warnings or suggestions so that end users easily understand the code.

Types of JavaScript comments

Two types of JavaScript comments:

  1. Single-line Comment
  2. Multi-line Comment

Single-line Comment

Single-line comment is represented by double forward slashes (//). Any text between double forward slashes (//) and end of line will be ignored while program is executed.

eg. Comment added before the statement.

eg. Comment added after the statement.

Output

Multi-line comment

Multi-line comments can be used for single as well as multi-line comments. Multi-line comments start with /* and end with */. The text between them will be ignored by JavaScript.

/* Write comment here */

Example