//我不明白爲什麼這不工作執行上下文和((此對象))
y = 'window';
var x = {
y : 'x',
func : function(){
return function(){
return this.y
}
}
};
x.func()();
// when I execute x.func()() I understand why it should return y
// x.func() would return a function in the global context and then execute it ' should return 'window' '
y = 'window'
var x = {
y : 'x',
func : function(){
return function(){
return this.y
}()
}
};
x.func();
爲什麼這段代碼也返回「窗口」是x對象的內部執行
的可能重複[Javascript「這個」嵌套函數內的指針](http://stackoverflow.com/questions/9644044/javascript-this-pointer-within-nested-function) – 2014-08-31 02:49:02