1var arr = [55, 44, 65,1,2,3,3,34,5];
2var unique = [...new Set(arr)]
3
4//just var unique = new Set(arr) wont be an array
1// usage example:
2var myArray = ['a', 1, 'a', 2, '1'];
3var unique = myArray.filter((v, i, a) => a.indexOf(v) === i);
4
5// unique is ['a', 1, 2, '1']
1const myArray = ['a', 1, 'a', 2, '1'];
2const unique = [...new Set(myArray)]; // ['a', 1, 2, '1']
1function onlyUnique(value, index, self) {
2 return self.indexOf(value) === index;
3}
4
5// usage example:
6var a = ['a', 1, 'a', 2, '1'];
7var unique = a.filter(onlyUnique);
8
9console.log(unique); // ['a', 1, 2, '1']