javascript is set contains code example
Example 1: javascript check if set contains
var mySet = new Set();
mySet.add('foo');
mySet.has('foo'); // returns true
mySet.has('bar'); // returns false
var set1 = new Set();
var obj1 = {'key1': 1};
set1.add(obj1);
set1.has(obj1); // returns true
set1.has({'key1': 1}); // returns false because they are different object references
set1.add({'key1': 1}); // now set1 contains 2 entries
Example 2: set.contains in javascript
const set = new Set();
set.add(1);
set.add(2);
set.add(3);
console.log(set.has(2)); //true
console.log(set.has(4)); //false