1、原型链继承
function Parent() {
this.name = 'Mike'
}
function Child() {
this.age = 12;
}
Child.prototype = new Parent();//Child继承Parent,通过原型,形成链条
var test = new Child();
console.log(test.age);
console.log(test.name);//得到被继承的属性
//继续原型链继承
function Brother() {//brother构造
this.weight = 60;
}
Brother.prototype = new Child();//继续原型链继承
var brother = new Brother();
console.log(brother.name);
console.log(brother.age);
大约 1 分钟