猿问

javascript中this的指向的疑惑

functiona(){};
a.prototype.testThis=function(){
console.log(a.prototype==this);//false
console.log(a==this);//false
console.log(b==this);//true
};
varb=newa();
b.testThis();//
按理说,prototype是一个对象,对象的this应该指向对象本身,也就是prototype,经过测试,它不指向a.prototype,也不指向a,而指向b。
慕容3067478
浏览 330回答 2
2回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答