javascript array as set code example
Example 1: array to set javascript
const myArray = [1,2,3,1,5,8,1,2,9,4];
const unique = [...new Set(myArray)]; // [1, 2, 3, 5, 8, 9, 4]
const myString = ["a","b","c","a","d","b"];
const uniqueString = [...new Set(myString)]; //["a", "b", "c", "d"]
Example 2: object set js
let nombres = [10, 45, 75, 10 ,24,45 ] ;
//let monSet = new Set(nombres) ;
let monSet = new Set() ;
monSet.add('100') ;
monSet.add('280') ;
//monSet.delete('100');
console.log(monSet.size) ;