介绍,super表示当前子类的父类,
在子类中,如果子类需要代用构造函数constructor,则这个constructor中必须有super关键字,否则会报错
class Aniaml {name: stringconstructor(name:string) {this.name=name}sayHelly() {console.log('hello')}}class Dog extends Aniaml {age: numberconstructor(name: string, age: number) {//子类新增的构造函数super(name)this.age=age //添加属性age}}let dog = new Dog('小狗',3)dog.sayHelly() //继承的方法console.log(dog.age) //自己的属性

如果不加super 则会向上面那样报错
这样的话在子类中也可以用过super方法来调用父类
