For a normal ("Native") JavaScript objects, where the property name is a valid identifier, the expressions x.y
and x["y"]
are always semantically equivalent.
对于普通(“Native”)JavaScript对象,其中属性名称是有效标识符,表达式x.y和x [“y”]始终在语义上等效。
Is this equivalency guaranteed for Host Objects?
主机对象是否保证等效?
[..an] object supplied by the host environment to complete the execution environment of ECMAScript.
[..an]由主机环境提供的对象来完成ECMAScript的执行环境。
If not, are there notable exceptions? (In Cocoon, Crosswalk, IE, etc?)
如果没有,是否有明显的例外情况? (在Cocoon,Crosswalk,IE等?)
In particular I am interested in the Window (window
) and other DOM Objects; and if there are any known "exceptions" to the expected behavior, or if there are any environments in where such is possible.
特别是我对Window(窗口)和其他DOM对象感兴趣;如果预期行为有任何已知的“例外”,或者存在可能的环境。
1 个解决方案
#1
2
It should be identical. From Section 11.2.1 (Property Accessors) of the Ecma-262 Edition 5.1, we have:
它应该是相同的。从Ecma-262 Edition 5.1的第11.2.1节(属性访问者),我们有:
Properties are accessed by name, using either the dot notation:
使用点表示法按名称访问属性:
MemberExpression . IdentifierName CallExpression . IdentifierName
or the bracket notation:
或括号表示法:
MemberExpression [ Expression ] CallExpression [ Expression ]
The dot notation is explained by the following syntactic conversion:
点符号由以下语法转换解释:
MemberExpression . IdentifierName
is identical in its behaviour to
它的行为是完全相同的
MemberExpression [ <identifier-name-string> ]
and similarly
和类似的
CallExpression . IdentifierName
is identical in its behaviour to
它的行为是完全相同的
CallExpression [ <identifier-name-string> ]
#1
2
It should be identical. From Section 11.2.1 (Property Accessors) of the Ecma-262 Edition 5.1, we have:
它应该是相同的。从Ecma-262 Edition 5.1的第11.2.1节(属性访问者),我们有:
Properties are accessed by name, using either the dot notation:
使用点表示法按名称访问属性:
MemberExpression . IdentifierName CallExpression . IdentifierName
or the bracket notation:
或括号表示法:
MemberExpression [ Expression ] CallExpression [ Expression ]
The dot notation is explained by the following syntactic conversion:
点符号由以下语法转换解释:
MemberExpression . IdentifierName
is identical in its behaviour to
它的行为是完全相同的
MemberExpression [ <identifier-name-string> ]
and similarly
和类似的
CallExpression . IdentifierName
is identical in its behaviour to
它的行为是完全相同的
CallExpression [ <identifier-name-string> ]