// 定义父类
class Father {
constructor(name, age) {
this.name = name;
this.age = age;
}
show() {
console.log(`我叫:${this.name}, 今年${this.age}岁`);
}
};
// 通过extends关键字实现继承
class Son extends Father {};
let son = new Son('王先生', 9000);
son.show(); // 我叫王先生 今年9000岁