关于this的指向问题
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>this指向问题</title> </head> <body> <script> var name ="windowName"; var a ={ name:'cherry', fn:function () { console.log(this.name) } } window.a.fn() //只看最后一个调用者(这里就是a) </script> </body> </html>
运行结果