关于 JavaScript 中不同地方的 this 指向。
本文中所有 Demo 均在 RunJS 中运行。
函数对象本身
当函数作为构造器被调用时,this 指向自身。
function constructor(){
console.log(this);
}
new constructor();
关于 JavaScript 中不同地方的 this 指向。
本文中所有 Demo 均在 RunJS 中运行。
当函数作为构造器被调用时,this 指向自身。
function constructor(){
console.log(this);
}
new constructor();