Answers for "remove duplicates from one array"

0

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']
Posted by: Guest on March-16-2021
1

javascript filter array remove duplicates

// Using the Set constructor and the spread syntax:

arrayWithOnlyUniques = [...new Set(arrayWithDuplicates)]
Posted by: Guest on December-21-2020

Code answers related to "remove duplicates from one array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language