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 ...

Get Mastering JavaScript Object-Oriented Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.