Comments in JavaScript

With JavaScript comments can be used to explain JavaScript code and make it more readable. JavaScript comments can also be used to prevent execution, when testing alternative code. In JavaScript we can use C, C++ style comments. There are two types of Comments :

1. Single Line Comment :

A single-line JavaScript comment begins with double forward slash (). Any text between  and the end of the line will be ignored by JavaScript. For example :
<script type="text/javascript">
  // print hello world on the page
  document.write(" Hello world !!.");
  // Example of single line comment

2. Multiline comment :

A multi-line JavaScript comment begins with forward slash and asterisk ( /* ), and end with the reverse asterisk and forward slash ( */ ). Any text between /* and */ will be ignored by JavaScript. For Example :
<script type="text/javascript">
    my first JavaScript to
    print hello world on the page.

    document.write(" Hello world !!.");
  /*Example of multi-line comment
    in JavaScript */