How to Write Comments in Javascript (Single and Multiline)

Last Updated on April 18, 2023 by Roshan Parihar

How to Write Comments in Javascript

You can write comments in Javascript using the symbols // and /**/. If you want to make single line commented, you have to put the symbol double slash(//) at the start of the line. A multiline comment can be done by using the text inside the start symbol /* and end symbol */

Below are the different ways of writing comments in Javascript with examples.

Write Comments Using Javascript Single Line Comment

Syntax

You can use symbol // at the start of the line, which you want to make commented. It’s the same way of commenting out a line of code as you use in PHP.

See the example given below.

Output

Click below button to see result.


Write Comments Using Javascript Multi-Line Comment

You can use Javascript multiline comment system to make more than one line commented. Use the symbol /* to the start of the comment and */ to the end of the comment to create a multiline comment system in Javascript.

Output

Click below button to see result.


You must also read.