remove repeated item from array code example
Example 1: javascript remove duplicates from array
unique = [...new Set(arr)]; // where arr contains duplicate elements
Example 2: remove duplicates from array javascript
function onlyUnique(value, index, self) {
return self.indexOf(value) === index;
}
// usage example:
var a = ['a', 1, 'a', 2, '1'];
var unique = a.filter(onlyUnique);
console.log(unique); // ['a', 1, 2, '1']