December 2017
Beginner
372 pages
10h 32m
English
In object-oriented programming, inheritance allows us to extend the functionality of a class from a parent class. In TypeScript, we use a keyword, extends, in a child class and refer the parent class. By extending the functionality in the child class, we can have access to all the public members of the parent class:
class Editor { constructor(public name: string,public isTypeScriptCompatible : Boolean) {} details() { console.log('Editor: ' + this.name + ', TypeScript installed: ' + this.isTypeScriptCompatible); }}class VisualStudio extends Editor{ public OSType: string constructor(name: string,isTypeScriptCompatible : Boolean, OSType: string) { super(name,isTypeScriptCompatible); this.OSType = OSType; }}let VS = new VisualStudio('VSCode', ...Read now
Unlock full access