Comment Statements (JavaScript)

Causes comments to be ignored by the JavaScript parser.

Single-line Comment:
// comment 
Multiline Comment:
Note: The comment argument is the text of any comment you want to include in your script. 


The condStatement argument is conditional compilation code to be used if conditional compilation is activated. If Syntax 3 is used, there can be no space between the "//" and "@" characters.

Use comments to keep parts of a script from being read by the JavaScript parser. You can use comments to include explanatory remarks in a program.

If Syntax 1 is used, the parser ignores any text between the comment marker and the end of the line. If Syntax 2 is used, it ignores any text between the beginning and end markers.

Syntaxes 3 and 4 are used to support conditional compilation while retaining compatibility with browsers that do not support that feature. These browsers treat those forms of comments as syntaxes 1 and 2 respectively.

The following example illustrates the most common uses of the comment statement.

function myfunction(arg1, arg2){
   /* This is a multiline comment that
      can span as many lines as necessary. */
   var r;
   // This is a single line comment.
   r = arg1 + arg2; // Sum the two arguments.

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards. See Version Information.

Community Additions