What are alternative / better ways to check if a JavaScript object is Map or Set than:
Object.getPrototypeOf(map) === Map.prototype
Object.getPrototypeOf(set) === Set.prototype
What are alternative / better ways to check if a JavaScript object is Map or Set than:
Object.getPrototypeOf(map) === Map.prototype
Object.getPrototypeOf(set) === Set.prototype
Use instanceof
:
var foo = new Set;
foo instanceof Set; // True!
foo instanceof Map; // False!