With regards to reserved words there is a small distinctions between the “Identifiers” used for the likes of variable or function names and the “Identifier Names” allowed as properties of composite data types.
For example the following will result in an illegal syntax error:
var break = true;
Uncaught SyntaxError: Unexpected token break
However the name is deemed valid as a property of an object (as of ECMAScript 5+):
var obj = {
break: true
};
console.log(obj.break);
To quote from this answer:
From the ECMAScript® 5.1 Language Specification:
Section 7.6
Identifier Names are tokens that are interpreted according to the grammar given in the “Identifiers” section of chapter 5 of the Unicode standard, with some small modifications. An Identifier
is an IdentifierName
that is not a ReservedWord
(see 7.6.1).
Syntax
Identifier ::
IdentifierName but not ReservedWord
By specification, a ReservedWord
is:
Section 7.6.1
A reserved word is an IdentifierName
that cannot be used as an Identifier
.
ReservedWord ::
Keyword
FutureReservedWord
NullLiteral
BooleanLiteral
This includes keywords, future keywords, null
, and boolean literals. The full list of keywords are in Sections 7.6.1 and literals are in Section 7.8.
The above (Section 7.6) implies that IdentifierName
s can be ReservedWord
s, and from the specification for object initializers:
Section 11.1.5
Syntax