JavaScript 函数的 this 指向
this 指向
function fn(){
// this 当前执行代码的环境对象
alert(this)
}
// 事件函数下的this 指的就是事件源
document.onclick = fn;
// [object Window]
// js 声明 如果你是在全局环境下声明的 变量 还是 函数 都默认加到window下面
// window.fn();
fn();

评论区