Using reserved words as property names, revisited

In ECMAScript, starting from ES5, reserved words may be used as object property names “in the buff”. This means that they don’t need to be “clothed” in quotes when defining object literals, and they can be dereferenced (for accessing, assigning, and deleting) on objects without having to use square bracket indexing notation.

That said, reserved words may still NOT be used as identifier names. This is stated quite unambiguously in the spec and is stated somewhat emphatically here (if you don’t want your eyes to bleed by having to read the actual language spec)…

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Reserved_Words

The following are keywords and may not be used as variables,
functions, methods, or object identifiers, because ECMAScript
specifies special behavior for them:

Leave a Comment