December 2017
Beginner
372 pages
10h 32m
English
Super is a TypeScript keyword that refers to the parent class. If we define a constructor to the child class, it's mandatory to call the constructor of the parent class explicitly, using the super keyword. In the following example, we have a constructor for our child class, TypeScript:
class Book { constructor(public author:string, public title:string, public length: number){ } getFullTitle(): string { return `${this.title} by ${this.author}`; };}class TypeScript extends Book{ constructor(author:string,title:string, length: number, public releaseDate:string){ super(author,title,length); }}
In this case, we need to call super so as to pass the required parameters to the constructor function of the parent class.
Read now
Unlock full access