先看一下代码:
function Parent(name){
this.name = "liu";
}
function Child(age){
this.age = age;
}
Child.prototype = new Parent();
var child1 = new Child(19);
alert(child1.name+" "+child1.age);//liu 19
Child明明继承的是Parent的prototype,而name属性是属于Parent构造函数的,那为什么Child实例会有name属性呢?
FFIVE
相关分类