(function?Foo(){
????this.num=123;
????console.log(this);//window
????(function?fn1(){
????????console.log(this)//window
????}());
})();函數Foo是在全局環境下調用的所以this指向window,但是為什么函數fn1是在Foo里面調用的,也是指向window.function?Foo(){
????this.num=123;
????console.log(this);//f
????(function?fn1(){
????????console.log(this)//window
????}());
}
var?f=new?Foo();當Foo作為f的構造函數時,Foo的this指向的是f,但是為什么fn1的this還是指向window.
在函數A里再創建一個函數B,為什么函數B的this指向window.
thrmagic
2017-09-19 09:57:44