哪位大神幫我解釋一下下面的代碼?1var name = "The Window"; var object = { name : "My Object", getNameFunc : function(){ return function(){ return this.name; }; } }; alert(object.getNameFunc()());2var name = "The Window"; var object = { name : "My Object", getNameFunc : function(){ var that = this; return function(){ return that.name; }; } }; alert(object.getNameFunc()());
關(guān)于閉包,如何理解?
躍然一笑
2019-02-13 10:19:13