javascript array unique Set spread code example
Example 1: js unique using set
let uniqueArray = [...new Set([5,5,2,2,2,4,2])];
// [5,2,4]
Example 2: how to get unique values from array in javascript without duplicate value
function uniqueArray2(arr) {
var a = [];
for (var i=0, l=arr.length; i<l; i++)
if (a.indexOf(arr[i]) === -1 && arr[i] !== '')
a.push(arr[i]);
return a;
}