//构造函数的继承
function Father(name, age) {
this.name = name
this.age = 20
this.skill = function () {
console.log('coding');
}
}
function Son(height, weight) {
Father.call(this, 'ls')
this.height = height
this.weight = weight
}
let son1 = new Son(21, 20)
console.log(son1);
//class类的继承
class Father2 {
constructor(name, age) {
this.name = name
this.age = 20
}
skill() {
console.log('11212121');
}
}
class Son2 extends Father2 {
constructor(height, weight) {
super('zs')
this.height = height
this.weight = weight
}
}
let son2 = new Son2(30, 50)
console.log(son2);