标签:obj js闭包 调用 -- OLE window var bsp log
<script>
var name = "The Window";
var object = {
name : "My Object",
getNameFunc : function(){
console.log("11111");
console.log(this); //this == object //调用该匿名函数的是对象
return function(){
console.log("22222");
console.log(this); //this == window //匿名函数下的匿名函数
return this.name;
};
}
};
alert(object.getNameFunc()());
//--
var name = "The Window";
var object = {
name : "My Object",
getNameFunc : function(){
var that = this;
return function(){
console.log("33333");
console.log(this); //this==window
console.log("44444");
console.log(that); //that==object
return that.name;
};
}
};
alert(object.getNameFunc()());
</script>
标签:obj js闭包 调用 -- OLE window var bsp log
原文地址:https://www.cnblogs.com/enych/p/8966592.html