子类既继承了父类this中的属性,又继承了父类原型中的属性
子类实例对象既是 父类 的实例,又是 子类 的实例
function Parent(name, age) {
this.name = name;
this.age = age;
}
Parent.prototype.say=function(){ //给父级原型上添加一个方法
console.log(this.name);
}
function Child(name, age){
Patent.call(this, name, age) //子级既继承了父级this中的属性,
}
Child.prototype.say=Parent.prototype.say //子级继承了父级原型中的属性
var person = new Child("张三", 30)
person.say(); //张三