function Dog(name, age) { this.name = name; this.age = age; this.bark = function() { this.name += " hello"; console.log(this.name); (function() { this.name += "a"; console.log(this.name); })(); }};let dog = new Dog("tep", 2);dog.bark();誰能告訴我這里發生了什么事嗎?當我打開控制臺時,它打印 2 行,分別是泰普你好A每次我重新加載頁面時,它都會繼續在第2行中添加“a”,并且我在窗口對象中看到,有屬性“name”泰普你好啊
js 作用域和 window 對象?
慕的地6264312
2023-07-14 09:54:39