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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.