日期:2014-05-16  浏览次数:20333 次

javascript闭包问题
  <script type="text/javascript">
window.onload = function(){
var name = "The Window";
var object = {
name : "My Object",
getNameFunc : function(){
return function(){
return this.name;
}
}
}
alert(object.getNameFunc()());

var name = "The Window";
var object = {
name : "My Object",
getNameFunc : function(){
var that = this;
return function(){
return that.name;
}
}
}
alert(object.getNameFunc()()); 
}
 </script>