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)...
在ECMAScript中,从ES5开始,保留字可以直接用作对象属性名称。 这意味着,当定义对象字面量时,它们不需要使用引号,并且可以在对象上直接引用(访问,分配和删除),而不必使用方括号索引符号。
也就是说,保留字可能仍然不能用作标识符名称。 这是在规范中非常明确地说明,并在这里有些强调...
The following are keywords and may not be used as variables, functions, methods, or object identifiers, because ECMAScript specifies special behavior for them:
以下是关键字,不能用作变量,函数,方法或对象标识符,因为ECMAScript为它们指定了特殊的行为:
网友评论