Comment (// and /* ... */) (Delimiter)

Mark a multi-line comment block.

Availability:

ECMAScript edition - 2
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Netscape Enterprise Server - 2.0
Opera - 3.0
JavaScript syntax:-/* First line of comment text
-// Comment text
-Second line of comment text
-Third line of comment text */

There are two kinds of comment blocks supported by JavaScript. They each have a different kind of delimiter.

Single-line comments commence with a pair of slash characters (//) and stop at the end of the current line.

Multi-line comments start with a slash-asterisk (/*) and finish at the first following asterisk-slash (*/). This means you cannot nest multiple line comment blocks inside one another. The disadvantage with that is that it is common practice in some languages to comment out sections of code by marking the start and end of the inactive sections as a multi-line comment block. This won't work if there are any multi-line comment blocks anywhere in this inactive block. A better technique, although slightly more cumbersome is to use single line comments (//) to 'switch-off' the lines of code you want to deactivate. Thus:

   //a = 1000;

   //b = 2000;

   //c = 3000;

See also:Comment, Lexical convention, Line, Line terminator, Multi-line comment, Single line comment

Cross-references:

ECMA 262 edition 2 - section - 7.3

ECMA 262 edition 3 - section - 7.4