javascript Set find code example
Example 1: check if set has value js
const mySet = new Set();
mySet.add(15);
console.log(mySet.has(33))
cosole.log(mySet.has(15))
Example 2: set in javascript
const firstSet = new Set([1, 2, 3]);
firstSet.add('hi');
firstSet.add(3);
firstSet.delete('hi');
console.log(firstSet.has('hi'));
console.log(firstSet);
for (const entry of firstSet.values()) {
console.log(entry);
Example 3: js new array from new set
return Array.from(new Set(this.posts.map(e => e.category)))
Example 4: object set js
let nombres = [10, 45, 75, 10 ,24,45 ] ;
let monSet = new Set() ;
monSet.add('100') ;
monSet.add('280') ;
console.log(monSet.size) ;