1、匿名函数中 this一般指向window对象

2、闭包函数中的this,指向window

var mod = {
        init: function(){
            console.log('this',this);
            var aa = function(){
                console.log('匿名函数中this',this);
            }
            aa();  //相对于自执行函数
            function bb(){
                console.log('闭包函数中的this',this);

            }
            bb();
        }
    }
    mod.init();

运行结果如下:

this指向(匿名函数问题)

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-04
  • 2021-12-11
  • 2022-12-23
  • 2021-04-20
  • 2022-12-23
相关资源
相似解决方案