How it works...

Object.assign adds all the properties from one object to another. Assigning all of the properties from the Launcher onto the new instance makes those available after the object is created. Remember that methods on this are simply properties on the prototype with function values. So, adding methods this way is the equivalent of defining these methods on the prototype. 

Thus, after applying this mix-in with Object.assign we can call methods defined as properties on Launcher as instance methods of  Rocket and InactiveRocket.

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.