和原型继承有什么不同呢?
分别的用处是什么呢?
需要仔细体会
function Parent() {
this.name = 'mike';
}
function Child() {
this.age = 12;
}
Child.prototype = new Parent();
let child1 = new Child();
console.log(child1.age);
console.log(child1.name);
function Brother() {
this.weight = 60;
}
Brother.prototype = new Child();
let brother1 = new Brother();
console.log(brother1.weight);
console.log(brother1.age);
console.log(brother1.name);