Using static methods to work with all instances

It can be a good idea to organize methods on a class, rather than on an instance of a class. One example is the Manager pattern. This pattern is useful when an object is expensive to create, or will be reused a lot.

In this recipe, we'll see how to use the static keyword to create a map for reusing instances of the Rocket class.

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.