JavaScript Comments

Comments in JavaScript are used to provide extra details about various aspects of a program. They are usually included at the start of a program to indicate its purpose, its author, and the date on which it was written. They also provide clarification about complicated statements in the program.

There are two types of comments used in JavaScript:

  • Single-line comments, and
  • Multi-line comments

Single-Line Comments

These comments are only on a single line and cannot move beyond that. They are represented using a double slash (//). An example of single-line comments in JavaScript is:

Output

JavaScript Single-line comments

Multi-Line Comments

These comments can be extended over multiple lines. They are represented using /* i.e slash asterisk (/*……….*/). Multi-line comments cannot be nested. An example of multi-line comments in JavaScript is:

Output

JavaScript Multi-line comments

JavaScript Loops
JavaScript Variables
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading