How it works...

This recipe differs from the previous simple extension example. By implementing a constructor on InactiveRocket, we are able to pass a different set of arguments. The lastFlown property is unique to InactiveRocket. Thus, we see that property on instances of InactiveRocket, but not on instances of Rocket.

You'll notice that the super method is called in the constructor of InactiveRocket. This manually executes the Rocket constructor for the current instance. That is why the name property is also attached. If we did not execute super, then the Rocket constructor would not have been called.

In this way, we've kept the properties from the parent class Rocket as well as adding an additional property to the InactiveRocket child class.

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

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