CHAPTER 4Inheritance

Inheritance is a very complex topic in JavaScript, much more so than in any other object oriented language. Unlike most other OO languages, where a simple keyword will allow you to inherit from a class, JavaScript requires a series of steps in order to pass on public members in the same way. To further complicate the issue, JavaScript is one of the few languages that uses prototypal inheritance (we will show you how this is actually a huge benefit). Because of the flexibility of the language, you can choose to use standard class-based inheritance, or the slightly trickier (but also potentially more efficient) prototypal inheritance.

In this chapter, we look at the techniques that can be used to create subclasses in JavaScript, ...

Get Pro JavaScript™ Design Patterns 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.