Implementing multiple inheritance
The prototypal mechanism of inheritance leads us to the conclusion that JavaScript supports single inheritance. In fact, since an object has just one prototype link and we can assign just one prototype object to a constructor function, we can conclude that an object can inherit features from just one other object. However, the flexibility of JavaScript allow us to implement multiple inheritance in a simple way.
But what is multiple inheritance? It is the ability to inherit features from more than one object or class at the same time. Suppose, for example, that we have two constructors or classes: Developer and Student. We want to be able to create objects that represent developers who study, that is, objects 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