在 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>
js 函數相互調用時,this 指向
MMTTMM
2019-03-06 15:08:15