给定以下代码,为什么不(obj.foo)()接收windowas this?在我看来,括号被忽略了,而不是被当作一个表达式来计算foo?
window.bar = 'window';
const obj = { bar: 'obj' };
obj.foo = function() {
console.log(`Called through ${this.bar}`);
}
obj.foo(); // Called through obj
(obj.foo)(); // Called through obj - Why?
(0, obj.foo)(); // Called through window
(true && obj.foo)(); // Called through windowRun Code Online (Sandbox Code Playgroud)