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
相关文章
相关标签/搜索