function parent(name){
this.name=name;
this.say=function(){
console.log("dad's name: "+this.name);
}
}
function child(name){
this.pObj=parent(name);
this.pObj=parent;
this.pObj(name);
this.sayC=function(){
console.log("child's name: "+this.name);
}
}想知道这段代码中的this.pObj=parent(name);这一句和this.pObj=parent;
this.pObj(name);这两句有什么区别吗?为什么第一种写法无法继承而第二种可以呢?感觉上是一回事呀。
添加回答
举报
0/150
提交
取消