Skip to main content

Posts

Showing posts with the label TypeScript Inheritance and Examples

TypeScript - Inheritance and Examples

Inheritance -  TypeScript is supports the concept of Inheritance. Inheritance has ability of a program to extend existing classes to create new ones. The extended class is called parent class or super class and the newly created classes are called child class or sub class. Inheritance can be classified as - 1.      Single - every class can at the most extend from one parent class 2.      Multiple - doesn’t support multiple inheritances in TypeScript. 3.      Multi-leve l Stayed Informed –   Learn Angular 2 with TypeScript A class captains the Public, Private, Protected and Read-only modifiers and Public by default. You can see the below example, the class User and each members are public by default. Example as, class Employee { empName: string ; constructor (name: string ) { this .empName = name; } salary(salary: number = 10000 ) { console.log( 'Hello...