February 2019
Beginner
694 pages
18h 4m
English
The constructor of a class is, however, just a function. In the same way that we can use the super keyword in a constructor, we can also use the super keyword when a base class and its derived class use the same function name. This technique is called function overriding. In other words, the derived class has a function name that is the same name as that of a base class function, and it overrides this function definition. Consider the following code:
class BaseClassWithFunction { public id : number | undefined; getProperties() : string { return `id: ${this.id}`; } } class DerivedClassWithFunction extends BaseClassWithFunction { public name: string | undefined; getProperties() : string { return `${super.getProperties()}` ...Read now
Unlock full access