class继承

函数

function Student(name) {
    this.name = name;
}

Student.prototype.hello => alert("name is "+ this.name);

Class类

class Student {
    constructor(name) {
        this.name = name;
    }

    hello() {
        alert('name is '+this.name);
    }
}

class采用constructor构造一个对象



class继承

class的继承十分方便,引入extends Obj就可以了
class Student extends StudentList {}
extends表示继承的原型链来自于StudentList
super()将this指向该对象,原型继承

class Cat extends Animal {
    constructor(name){
        super();
        this.name = name;
    }

    say() {
        alert('Hello,' + this.name + '!')
    }
}
夹具
原文地址:https://www.cnblogs.com/jilaokang/p/8668123.html