Polymorphism
Polymorphism is the last important concept of OOP that you need to understand. Polymorphism basically means many forms/shapes, and it actually exists at different levels in OO languages.
First, functions can be polymorphic: you can create multiple variants of a given function that all accept arguments of different types. This is generally known as function overloading.
Another type of polymorphism is called parametric polymorphism, or generics, as we will see in the case of TypeScript. We will learn more about generics later in the book.
Another form of polymorphism is subtyping. For example, some programming languages allow you to define functions taking an object of the Animal type, but still work fine if passed an object that ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access