The Javascript Set constructor can create Set objects.
It can create set from unique values of any types.
new Set([iterable])
let set1 = new Set(); set1.add(1);/* w w w . j a v a 2 s. c o m*/ set1.add(2); set1.add(3); console.log(set1); let a = [1, 2, 3, 4]; console.log(a); let mySet = new Set(a) console.log(mySet); console.log(mySet.size);