What are the different ways of making comments in JavaScript?

Solution

JavaScript supports both single line comment as well as multiline comment as shown in below examples:

Single Line Comment

// This variable holds value of data variable
var  data ="Educational Website";

Any text/code after // is considered as comment in JavaScript.

Multi-Line Comment

/* This code is used to store value of
    various elements of HTML DOM 
*/
var domElement1 = document.getElementByID("div1").value;

Any text/code between /* and */ is considered comment in JavaScript.

Share this thread

Comments

Comments
comments powered by Disqus

Navigation

Social Media