class Animal {
constructor(name, age) {
this.name = name;
this.age = age
}
showName() {
console.log(this.name);
}
}
class Cat extends Animal {
constructor(name, age, sex) {
super(name, age);
this.sex = sex;
}
}
let cat = new Cat('jake', 18, 'female');
cat.showName(); // jake
ES6 uses class to achieve inheritance
Guess you like
Origin blog.csdn.net/weixin_43757001/article/details/115368643
Ranking