EN
JavaScript - check if object is Set type
0 points
In this article, we would like to show you how to check if an object is a Set type in JavaScript.
Quick solution:
xxxxxxxxxx
1
var set = new Set();
2
3
console.log(set instanceof Set); // true
4
console.log(set.constructor === Set); // true
5
6
console.log({} instanceof Set); // false
7
console.log([1, 2, 3] instanceof Set); // false
8
console.log('text' instanceof Set); // false