/* and a terminating delimiter */.
During lexical analysis, the parser evaluates multi-line comments as whitespace (specifically, as token separators) rather than performing zero-width removal. Because they do not simply disappear to merge adjacent characters, inserting a comment within a single identifier or keyword splits the token and results in a SyntaxError.
Automatic Semicolon Insertion (ASI)
According to the ECMAScript specification, if a multi-line comment contains one or more line breaks, the parser treats the entire comment as aLineTerminator rather than standard whitespace. This distinction is critical because a LineTerminator can unexpectedly trigger Automatic Semicolon Insertion (ASI) when following restricted productions such as return, break, continue, throw, or yield.
Technical Limitations: Nesting
JavaScript multi-line comments cannot be nested. The lexical scanner reads the comment sequentially and terminates the comment block at the very first instance of the closing delimiter*/. If a multi-line comment contains another multi-line comment, the parser treats the inner comment’s closing delimiter as the end of the outer comment. The parser then resumes standard tokenization for the remaining text, which results in a SyntaxError when it eventually encounters the outer comment’s dangling closing delimiter.
Tired of Poor JavaScript Skills? Fix That With Deep Grasping!Learn More





