April 2018
Intermediate to advanced
284 pages
5h 46m
English
| Tip 38 | Share Methods with Inheritance |
In this tip, you’ll learn how to extend classes and call parent methods.
In the previous tip, you learned how to create basic classes with properties and methods. You may recall that classes in JavaScript were highly anticipated and slightly dreaded. The core of the controversy is inheritance.
Inheriting methods on prototypes was a pretty complex process in early versions of JavaScript. First, you had to loop through the properties on an object; then, you had to check to see that each property existed specifically on an object as a property and not on the object prototype. Then you had to copy the prototype from the parent to a new object before adding further methods.
It was hard.
With classes, inheritance ...
Read now
Unlock full access