How to Write Comments in Javascript (Single and Multiline)

Last Updated on May 1, 2024 by Roshan Parihar

To write comments in Javascript, use the symbols // and /**/. Comments are useful to explain the workings of codes.

If you want to make a single-line comment, you have to put the symbol double slash(//) at the start of the line. A multi-line comment can be done by using the text inside the start symbol /* and the end symbol */. Let’s find out with the examples given below.

Single Line Comment in Javascript

If you want to add a single-line comment, you can use the symbol // at the start of the line, in which you want to comment.

Examples 1

Output

Click below button to see result.


Multi-Line Comments in Javascript

If you want to add multi-line comments in javascript, Use the symbol /* to the start of the comment and */ to the end of the comment. You can use the Javascript multiline comment system to make more than one-line comments.

Examples 2

Output

Click below button to see result.