var a = function () {
let i = 0;
console.log(this);
return function () {
i++;
console.log(i);
console.log(this);
}
}
var b = { a };
b.a()();
第一个this是a
可以理解, 第二个this
为什么是window
.
这个可以分解一下
b.a()()
:function
的直接调用,在浏览器中,this
是指向window
的