How it works...

The classInactiveRocket extends Rocket. This means that all of the properties on the prototype of Rocket end up on the instance of InactiveRocket unless they are overridden. The constructor is special, but it is also a property on the Rocket prototype. Therefore, when the two instances are created, the Rocket class constructor is executed for both the Rocket and InactiveRocket instances. So, we see the name property assigned on both instances.

We'll see how to override methods and other behaviors in future recipes.

Get ECMAScript Cookbook 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.