1. 全部的this关键字,在函数运行时,才能肯定它的指向
2. this所在的函数由哪一个对象调用,this就会指向谁
3. 当函数执行时,没有明确的调用对象时,则this指向window浏览器
由于箭头函数不具有本身的this,因此很是简单,伪装它不存在,就像这样:函数
var obj = { show: function(){ setTimeout(()=> { console.log(this); },0), } }
这下this的指向很是清晰了吧this
不能!! 试图改变箭头函数的this是徒劳的。code
var fn = () => { console.log(this); } fn.call(document); // 依然打印window