var name = "The Window"; var object = { name : "My Object", getNameFunc : function(){ return function(){ return this.name; }; } }; alert(object.getNameFunc()());
这一段返回的为什么是 The Window,子函数找变量不是一级一级网上找吗,找的不应该是My Object吗?
var name = "The Window"; var object = { name : "My Object", getNameFunc : function(){ var that = this; return function(){ return that.name; }; } }; alert(object.getNameFunc()());
返回的是My Object,这里面的var that = this改变了指向吗,这里的That是哪个对象?
GCT1015
RISEBY
相关分类