var o ={
m:function(){
var self = this;
console.log(this === o);//true
f();
function f(){
console.log(this === o);//false
console.log(self === o);//true
}
}
};
复制代码
this
为关键字,指向它的调用者。嵌套函数 f
中的this
指向全局对象