Chapter 8
Using Inheritance

JavaScript’s original implementation of inheritance was different from other mainstream languages in two ways. Although most mainstream languages provided class-based inheritance, JavaScript implemented prototypal inheritance. Furthermore, for the vast majority of programmers it was not clear how to effectively use inheritance in JavaScript. The syntax was confusing, error prone, and hard to maintain. Thankfully, the language has evolved and the syntax for inheritance is now much easier to use and understand.

The updated syntax is akin to Java and that may lead us to believe that the inheritance model of JavaScript is similar to that of Java—but that’s not true. JavaScript has always provided prototypal inheritance and that has not changed with the new syntax.

In this chapter we’ll start with a quick introduction to prototypal inheritance. Then you’ll learn the updated syntax for inheriting from existing classes. Along the way we’ll explore how to control the instance that is created when working with a class hierarchy.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.35.178