// 父类 class People{ constructor(name){ this.name = name; } eat(){ console.log(`姓名 ${this.name} eat something `) } } // 子类 class Student extends People { constructor(name, number) { super(name); this.number = number; } sayHi() { console.log(`姓名 ${this.name} , 学号 ${this.number} `) } } const aaa = new Student('lisi',100) console.log(aaa.name) console.log(aaa.number) aaa.sayHi() aaa.eat()