How it works...

The isA function compares the identity of the instance constructor property against the passed klass. This will be true if the instance argument is an instance of klass (in this case we are comparing an instance of the InactiveRocket class). It will return false for any other class, including Rocket.

Because we are comparing the constructor to the class directly, inheritance is not taken into account. If we were to use instanceOf, the function would return true for Rocket as well.

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.