this指向(匿名函数问题)

 

 

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();

运行结果如下:

 

posted @ 2015-09-25 13:18  freewalker  阅读(1081)  评论(0编辑  收藏  举报