document.onclick = function(){ // 普通函数的this是在运行的时候才临时绑定的,也就是说,函数不运行,你绝对不可能知道this是谁 // 下面这个函数若是是自调用,this就是window,好比状况1 // 若是是被别的对象调用的,this就是调用他的那个对象 好比状况2 function fn1(){ console.log(this) } // 状况1: fn1(); // 状况2: button.onclick = fn1(); // 箭头函数的this在建立的时候就肯定好了, // 箭头函数的this取决于位于谁的做用域内声明的, // 下面这个this在外面function中声名,绑定了外面function的this,这个this绑定了document let fn2 = () =>{ console.log(this) } }