JavaScript 習題:考察 this 指向以及做用域-1

// 請問下列代碼輸出什麼?爲何? function a(xx){ this.x = xx; return this; } var x = a(5), y = a(6); console.log(x.x); // undefined console.log(y.x); // 6 答案:函數中的 this 指向 window。 1. x = a(5) , x = window ; 2. y
相關文章
相關標籤/搜索