check if element in set js code example
Example 1: javascript check if set
if (typeof variable !== 'undefined') {
}
if (typeof variable === 'undefined') {
}
Example 2: check if set has value js
const mySet = new Set();
mySet.add(15);
console.log(mySet.has(33))
cosole.log(mySet.has(15))
Example 3: javascript check if set contains
var mySet = new Set();
mySet.add('foo');
mySet.has('foo');
mySet.has('bar');
var set1 = new Set();
var obj1 = {'key1': 1};
set1.add(obj1);
set1.has(obj1);
set1.has({'key1': 1});
set1.add({'key1': 1});