1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| class Person { constructor(name, age) { this.name = name; this.age = age; }
running() { console.log("running"); } eating() { console.log("eating"); } }
class Student extends Person { constructor(name, age, sno, score) { super(name, age); this.sno = sno; this.score = score; }
running() { console.log("哈哈哈"); super.running(); } studying() { console.log("studying"); } }
const stu = new Student("aaa", 18, 1, 90);
stu.running(); stu.eating(); stu.studying();
|