Are comments literally just stripped out of your source before parsing, or can they count as linebreaks and disrupt continuity in certain contexts?
'foo'.replace(/f/, 'b') //f->b
.replace(/o/, 'a') //o->a
.replace(/o/, 'r') /*o->r*/ ;
'foo'.replace(/x/, /*matches "x"*/ 'y');
var foo = ( true !== false ) ? // bikeshed
'bar' : /*if they're equal, which they won't be, we'll want 'baz'*/ 'baz';
You know, cause they say whitespace is “safe” and “insignificant” or whatever, but we all know there are exceptions to that. Are comments actually safe?
They’re ignored during parsing, if they were stripped out before parsing, the parser would need to scan the input twice.
ES5 Specification for comments.
The source code is tokenised as if the comments didn’t exist.