- 子类可以继承父类的全部内容(包括静态方法)
{
class Person {
constructor(n, s) {
this.name = n;
this.sex = s;
}
eat() {
console.log("吃饭");
}
static work() {
console.log("静态方法");
}
}
class Children extends Person {
constructor() {
super();
}
}
let s = new Children();
console.log(s);
Children.work();
}
- 多个继承
{
class Person {
constructor(n, s) {
this.name = n;
this.sex = s;
}
eat() {
console.log("吃饭");
}
static work() {
console.log("....");
}
}
class Children extends Person {
constructor(m, n, s) {
super(n, s)
this.money = m;
}
}
class Student extends Children {
constructor(n, s) {
super("钱", n, s);
}
job() {
console.log("上学");
}
}
let s = new Student();
console.log(s);
}