Detecting instances

To detect whether an object is an instance of a constructor, we can simply use the instanceof operator:

const component = new Component();component instanceof Component; 
The instanceof operator will be covered in more detail in Chapter 8, Operators.

Get Clean Code in JavaScript 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.