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 ...
Get Eloquent JavaScript 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.