我有一个非常基本的 javascript 问题,我什至无法制作适当的 Google 查询来回答它。例如:
function Parent(name){
this.name = name;
}
Parent.prototype.Child() = function (){
if(this.name == 'Sam'){ // This is the comparison that obviously doesn't work
/* Do something */
} else {
/* Do something else */
}
}
var Parent1 = new Parent('Sam');
var Child1 = new Parent1.Child();
在比较中是否有一个关键字可以用来代替 this 来访问 Parent 的“name”属性?
干杯!