TL;DR. Take me to the example!
JavaScript inheritance is all about prototype chaining. To create one, simply set the prototype of an instance of a subtype equal to the one of an instance of the supertype. I use Object.create()
for that.
There is one problem though: how to inherite the supertype's properties?.
This is where constructor stealing comes in.
The subtype can inherit supertypes properties, by calling the constructor of the supertype. I use call()
for that.
The combination of prototype chaining and constructor stealing is called pseudo classical inheritance, because it is not exactly like in class based languages, but does behave the same.