O'Reilly logo

Eloquent JavaScript by Marijn Haverbeke

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

Prototypal Inheritance

The whole terrarium detour should have given you some insight into the way objects are used in real programs. The rest of the chapter is devoted to a more in-depth look at inheritance and the problems related to inheritance in JavaScript.

First, let’s go over some theory. Students of object-oriented programming can often be heard having lengthy, subtle discussions about correct and incorrect uses of inheritance. It is important to bear in mind that inheritance, in the end, is just a trick that allows lazy programmers—and here I mean to use the word lazy in the most positive way possible—to write less code. Thus, the question of whether inheritance is being used correctly boils down to the question of whether the resulting ...

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