What are the different ways of making comments in JavaScript?


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 powered by Disqus


Social Media