HengistChan
HengistChan

Reputation: 23

What‘s the difference between "identifier" and "identifierName" in ECMAScript 2020?

https://262.ecma-international.org/11.0/#prod-IdentifierName I don't undestand well the difference between "identifier" and "identifierName" in ECMAScript 2020.

Upvotes: 1

Views: 106

Answers (2)

Michael Dyck
Michael Dyck

Reputation: 2438

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.)

Upvotes: 0

derM
derM

Reputation: 13691

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.

Upvotes: 1

Related Questions