在 hello() 中调用 world() ,为什么 world() 中的 this 指向的是 window?是不是因为在调用world()时,没有明确的使用对象或 this,所以 world() 中的 this 就指向了 window?希望能大家的得到解惑。<html><head><meta charset="utf8"></head><body><button id="btn1">hello world</button><script type="text/javascript"> document.querySelector("#btn1").addEventListener("click",hello); function hello() { console.log("hello 的 this") console.log(this) world(); } function world() { console.log("world 的 this") console.log(this) // window }</script></body></html>
添加回答
举报
0/150
提交
取消
