JavaScript Comments – JavaScript Single Line and Multiline Comments

Article By Rawat Digamber on
JavaScript comments are used to interpret JavaScript code, comments are used to make the other programmers or developers understand the code easily.

JavaScript comments are not executed by the browsers. JavaScritp offers two types of comments.

1. JavaScript – Single Line Comment

Single line comments are depicted by the two forward slashes //.

Check out the example for single line comment.

// Update header:
document.getElementById("header").innerHTML = "Hello World!";

// Update sidebar:
document.getElementById("sidebar").innerHTML = "Hey There!";

A single line comment above every line of code is very useful to make us understand the code.

2. JavaScript MultiLine Comment

JavaScript Multi-line comments begin with /* and end with */ symbol. The comment which goes between /* — comment here — */ will not be executed by the browser.

We've declared 3 values variables and assigned 
3 numerical values to all those 3 variables.

let x = 2;

let y = 4;

let z = 8;

JavaScript Multiline of comments is usually good for creating documentation.

Feel free to contact me, If you are looking for a freelance web and mobile app developer in India, with the following skills: Angular JS, Angular 2+, Node JS, Firebase, MongoDB, Ionic Framework and WordPress.

I also offer remote contracting services to clients across the globe.

Get Started