O'Reilly logo

Pro JavaScript™ Design Patterns by Dustin Diaz, Ross Harmes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required