-
Book Overview & Buying
-
Table Of Contents
Clean Code with TypeScript
By :
Inheritance is a cornerstone of OOP, which allows you to create new classes (subclasses) that inherit properties and behaviors from existing classes (superclasses). This promotes code reusability and reduces redundancy in your TypeScript applications.
TypeScript, being a superset of JavaScript, uses prototypal inheritance behind the scenes. Prototypal inheritance differs from the classical inheritance model used in languages such as Java or C++. In prototypal inheritance, objects inherit directly from other objects. However, TypeScript provides a class-based syntax that abstracts away the prototypal nature of inheritance, making it more familiar to developers coming from classical OOP languages. Let's explore these two models to understand their differences better.
Classical inheritance is used in languages such as Java and C++. Here, the inheritance hierarchy is more rigid. A subclass inherits from a superclass and has a fixed...