How to write comments in the JavaScript code
Learn, how to write a comments in JavaScript.
There are two ways to write a comments in JavaScript.
Single line comment
To write a singe line comment in JavaScript, we can use the forward slashes //
.
Example:
// this is a single line comment in JavaScript
Multiline comment or Block comment
/*
this is a multi-line
comment.
Hope
you
love me
*/
Why comments are helpful
-
Comments help us to read our code better in the future in case if we forgot what is happening on the particular line of code.
-
Comments can be helpful to the other developers who try to read our code.
-
Comments are also used to stop running a particular line in the code.
-
Comments are ignored by the interpreter.