var id =21; function testThis(){ setTimeout(function(){ console.log(this.id); },1000); } let testThis2 = ()=>{ setTimeout(function(){ console.log(this.id); },1000); } function testThis3(){ setTimeout(()=>{ console.log(this.id); },1000); } testThis(); testThis2(); testThis3(); testThis.call({id:42}); testThis2.call({id:42}); testThis3.call({id:42});為什么 testThis2.call({id:42}); console的是21呢。
關于es6箭頭函數的一些小問題
FFIVE
2018-10-10 13:14:03