Skip to main content

Single line and multi line comments in javascript


Comments plays a vital role in JavaScript that provide the information about a piece of the JavaScript.

Comments can be a single line or multi line. While debugging the large piece of code, comments can be used to prevent the execution of the code.

This tutorial explains about the single line and multi line comments.

Single Line Comments

Two forward slashes ( denoted by // ) creates a single line comment. Text written after the slashes till the end of new line, will not get executed.

Single line comments can be written before the statement of after the statement.

Before the statement.
// Declare a, assign the value of 2 
var a = 2;      
// Declare b, assign the value of a + 1
var b = a + 1;  
After the statement.
var a = 2;      // Declare a, assign the value of 2 
var b = a + 1;  // Declare b, assign the value of a + 1

Multi Line Comments

Multi line comments begins with forward slash and asterick ( denoted by /* ) and ends with asterick and forward slash ( denoted by */ ). Any text written inside multi line comments will not get executed. It is also called as block comments.

/* This is a multi line comment.  
It will not be displayed */  
document.write("Example of multi line comment");  

Single line comments becomes cumbersome when more number of lines needs to be commented.


Popular posts from this blog

eLitmus pH test for freshers

eLitmus has became more famous in conducting pH test for the fresh graduates in India. They will evaluate candidates across India and to provide a standard benchmark against which companies can compare them.


Who can apply

Candidates having/pursuing a degree in BE/B.Tech, MCA, ME/M.Tech or M.Sc(CS/IT) can apply for the pH test.

Companies recruiting from pH test

List of companies

Look at test centers

Check the upcoming pH tests

Look at the testimonials

Read what the candidates appeared for this exam says about eLitmus.

Test Pattern

Test duration : 2 hours
No of questions : 60

It will be asked from 3 categories,

Syllabus

20 : Problem solving
20 : Verbal ( You need to read the paragraph and answer the questions )
20 : Quantitative ( Data interpretation )

Four options will be provided for each question. Test will be conducted online.

Payment methods

Fresh graduates appearing for the test has to pay Rs 920/- as a test fee.

They can pay online or send a DD or in cash at Bangalore eLitmus office.

By Online: If y…