In this chapter, we explored the inheritance mechanism of JavaScript based on prototypes, which is objects that act as templates for other objects. We saw how objects can be linked each other through their prototypes to create a chain representing the inheritance hierarchy. Then, we talked about the creation of an inheritance relationship between constructor functions and about the simplicity of new ECMAScript 6 syntax for extending classes. Our discussion continued with the different ways to control inheritance: from overriding methods and properties to the implementation of protected members, from the prevention of object extension to the creation of immutable objects.
The chapter concluded with some examples of implementation of multiple inheritance and with the use of the mixin pattern with constructor functions and classes.
The next chapter will discuss interoperability between objects. We will see how we can define contracts, how to specify them through interfaces, and how to...