How to create Comments in Javascript

Description

Javascript uses C-style comments for both single-line and block comments.

A single-line comment begins with two forward-slash characters, such as this:

//This is a single line comment.

A block comment begins with /* and ends with */, as in this example:


/*
 * This is a multi-line
 * Comment
 */

Example


<!DOCTYPE HTML>
<html>
<body>
  <script type="text/javascript">
      //this is a comment
    document.writeln("This is a statement");
    document.writeln("This is also a statement");
    /* more comments<!--from w  w w  .  j  a v  a2  s  . c o m-->
       more comments
       more comments
       more comments
    */
  </script>
</body>
</html>

Click to view the demo





















Home »
  Javascript »
    Javascript Introduction »




Script Element
Syntax
Data Type
Operator
Statement
Array
Primitive Wrapper Types
Function
Object-Oriented
Date
DOM
JSON
Regular Expressions