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
指向全局对象
本文共 229 字,大约阅读时间需要 1 分钟。
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
指向全局对象
转载地址:http://oxoel.baihongyu.com/