February 2019
Beginner
694 pages
18h 4m
English
When using inheritance, both a base class and a derived class may have the same function name. This is most often seen with class constructors. If a base class has a defined constructor, then the derived class may need to call through to the base class constructor and pass through some arguments. This technique is called constructor overriding. In other words, the constructor of a derived class overrides, or supersedes, the constructor of the base class. TypeScript includes the super keyword to enable calling a base class's function with the same name. Consider the following classes:
class BaseClassWithConstructor { private id: number; constructor(_id: number) { this.id = _id; } } class DerivedClassWithConstructor extends ...Read now
Unlock full access