how to check set in string javascript code example
Example 1: check if set has value js
const mySet = new Set();
// Add value to set
mySet.add(15);
console.log(mySet.has(33)) // expected output: false
cosole.log(mySet.has(15)) // expected output: true
Example 2: add to set js
const mySet = new Set();
mySet.add(15);
mySet.add(33);
mySet.add(15);
for(let item of mySet) {
console.log(item)
// expected output: 15
// expected output: 33
}