When you use an object literal , then the property name can be any of the following:
IDName
String Literal
Numeric Literal
StringLiteral and NumericLiteral should be clear. What is an IdentifierName ?
Let's look at section 7.6 of the specification :
Identifier:
IdentifierStart
IdentifierName * IdentifierPart *
IdentifierStart ::
UnicodeLetter
$
_
\ UnicodeEscapeSequence
IdentifierPart ::
IdentifierStart
UnicodeCombiningMark
UnicodeDigit
UnicodeConnectorPunctuation
<ZWNJ>
<ZWJ>
So, IdentifierName really is any sequence of characters, as described above. Is the reserved word unimportant.
The names that you can use for variable and function names are called Identifier and are defined as:
Identifier::
IdentifierName, but not ReservedWord
You see that reserved words are explicitly excluded as opportunities for identifiers, but not for object properties.
However , you never know how a "good" parser is, and whether it follows all the rules. In addition, linting tools like JSHint usually warn you about using a reserved keyword, even though it is valid. To be safe, you must put such words in quotation marks and even use anchor notation to access it:
var foo = {'delete': ... } foo['delete'] = ....;
If this is too cumbersome, just do not use the reserved word as the name of the property. For example, instead of delete you can use remove .