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
1let a = ["1", "1", "2", "3", "3", "1"];
2let unique = a.filter((item, i, ar) => ar.indexOf(item) === i);
3console.log(unique);
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']
1var array3 = [1, 2, 4, 6, 1, 4, 9, 10, 2, 8];
2function findUniqueElements_3(array) {
3
4 for (let i = 0; i < array.length; i++) {
5 for (let j = i + 1; j < array.length; j++) {
6 if (array[i] == array[j]) {
7 array.splice(j, 1)
8 }
9
10 }
11 }
12 console.log(`from third way : ${array}`);
13}
14
15findUniqueElements_3(array3)