Inheritance – Overloading - TypeScript - JavaScript's Superset

Rumman Ansari   Software Engineer   2023-12-05 09:07:45   62  Share
Subject Syllabus DetailsSubject Details 1 Program
☰ TContent
☰Fullscreen

Table of Content:

JavaScript uses prototypical inheritance instead of classical inheritance.

TypeScript allows us to inherit from existing classes according to need. Here is a code snippet to explain:

	class Cube {
		length: number;
		constructor(length : number) {
			this.length = length;
		}
    }
	class Physics extends Cube {
		color: string;
		constructor(length: number, color: string) {
			super(length);
			this.color = color;
		}
	}
	var obj = new Physics(10, "yellow");
MCQ Available

There are 1 MCQs available for this topic.

1 MCQ