Arrow function blind this.

Arrow function blind this.

 

var Test= {
    foo:"test",
    func:function () {
        (() => {
            console.log(this.foo);
          //  console.log(self.foo);
        })();
    }
}
Test.func();//"test"

var Test= {
    foo:"test",
    func:function () {
        (function(){
            console.log(this.foo);
            //  console.log(self.foo);
        })();
    }
}
Test.func();//undefined

  

posted @ 2017-09-26 20:44  JadeofMoon  阅读(77)  评论(0编辑  收藏  举报