这次,我观察到了一些有趣的行为,我肯定想了解更多。
var doStuff = function() {
this.this = function() {
console.log("I'm the other this");
}
this.this(); //Is this legal to be used ?
};
doStuff.call(null);
输出
I'm the other this
最佳答案
'The syntactic grammar defines Identifier as an IdentifierName that is not a ReservedWord (see 11.6.2) '但是object properties can be accessed with MemberExpression . IdentifierName
,并且 IdentifierNames 不受该限制。
关于javascript - 如果这是 javascript 中的保留字,为什么我仍然可以将其设置为属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31765627/