Check if Object is of type Set in JavaScript

The instanceof operator is use to check the type of object 

The instanceof operator returns true if the prototype property of a constructor appears in the prototype chain of the object.

Right way to find type of object is the following

var someObj = new Set;
someObj instanceof Set; // True
someObj instanceof Map; // Flase

Tags:

Share:

Related posts