0
点赞
收藏
分享

微信扫一扫

js闭包函数

要想看懂闭包,好好理解吧!

一、变量的作用域复习

二、什么是闭包

三、闭包的作用

四、闭包的案例

更多案例

一、变量的作用域复习

二、什么是闭包

三、闭包的作用

四、闭包的案例

 

更多案例

var name = "The Window";
   var object = {
     name: "My Object",
     getNameFunc: function() {
     return function() {
     return this.name;
     };
   }
 };
console.log(object.getNameFunc()())
-----------------------------------------------------------------------------------
var name = "The Window";  
  var object = {    
    name: "My Object",
    getNameFunc: function() {
    var that = this;
    return function() {
    return that.name;
    };
  }
};
console.log(object.getNameFunc()())
举报

相关推荐

0 条评论