JavaScript - Comments
JavaScript - Comments:
JavaScript offer two forms of comments, block comments formed with /* */ and
line-ending comments starting with //.
The /* */ form of block comments came from a language called PL/I. PL/I chose
those strange pairs as the symbols for comments because they were unlikely to
occur in that language's programs, except perhaps in string literals. In
JavaScript, those pairs can also occur in regular expression literals, so block
comments are not safe for commenting out blocks of code. For example:
/*
var rm_a = /a*/.match(s);
*/
causes a syntax error. Therefore, we should avoid using block comment form, and
use the line-ending comment form instead. We can configure our editors to help
with this.
page revision: 0, last edited: 16 Nov 2016 19:02





