What is comments and types of comments in javascript?

                          For two reasons we can have comments in the code, one is to define the description of the specific code and the another thing is to prevent the execution of code .

There are two type of comments are available in javascript

1. Single line comment
2. Multiple line comment

Single line comment

Single line comment is used to comment a single line of code.

Syntax

//the code we need to comment

Example

// var total=0;

Multiple line comment

Multiple line comment is used to comment a block of coded that is multy line commenting.

Syntax

/*
the code we need to comment line 1
the code we need to comment line 2
the code we need to comment line 3
*/

Example

/*
var a=10;
var b=20;
var c=a+b;
*/

 

Leave a Reply

%d bloggers like this: