Learn JavaScript
Single and Multiple line comments

Single Line Comments

We use comments to describe the working of our code to others and our future self. The comments are ignored when the code executes. Therefore, they are not visible in the output.

We can add single-line comments using two forward-slash characters //.

In the example given below, the comment fully occupies the whole line.

Anything to the right side of // becomes a comment.

In the example given below, only the text on the right side of // is a comment. The code on the left side works normally.

The comments should be kept precise and meaningful.