"use strict"; (function () { // 父类 class Animal { constructor(name) { this.name = name; } eat() { console.log("吃的真香"); } } class Cat extends Animal { /** * 若子类继承父类 * 子类的构造函数中必须对父类的构造函数进行重新 */ constructor(name, age) { super(name); this.age = age; } } let cat = new Cat('喵喵', 3); console.log(cat.name); console.log(cat.age); cat.eat(); })();