一.程序一
<script> var name = "The Window"; var Object_a = { name : "My Object", getNameFunc : function(){ var that = this; return function(){ return that.name; }; } }; alert(Object_a.getNameFunc()()); </script>
?
结果:My Object
?
二.程序二
<script> var name = "The Window"; var Object_a = { name : "My Object", getNameFunc : function(){ return function(){ return this.name; }; } }; alert(Object_a.getNameFunc()()); </script>
?
结果:The Window