https://262.ecma-international.org/11.0/#prod-IdentifierName I don't undestand well the difference between "identifier" and "identifierName" in ECMAScript 2020.
Asked
Active
Viewed 75 times
1
-
Can you quote a short snippet of the relevant parts here…? – deceze Jun 16 '21 at 10:08
2 Answers
1
The answer is given in the Documentation linked by your self, in one concise sentence:
The syntactic grammar defines Identifier as an IdentifierName that is not a ReservedWord.

derM - not here for BOT dreams
- 13,081
- 4
- 49
- 89
0
In the ECMAScript specification, the lexical grammar doesn't 'know' anything about reserved words; any word-like thing is recognized as an IdentifierName. It's then up to the syntactic level to decide how to deal with an IdentifierName. If an IdentifierName doesn't match the ReservedWord production, then it qualifies as an Identifier, and (to a first approximation) can be used in all the places you'd expect an identifier. (The complete rules are somewhat complicated: see 12.6.2 Keywords and Reserved Words for a summary.)

Michael Dyck
- 2,153
- 1
- 14
- 18