Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

JavaScript remove duplicate items

function onlyUnique(value, index, self) {
  return self.indexOf(value) === index;
}

// usage example:
let a = ['a', 1, 'a', 2, '1'];
let unique = a.filter(onlyUnique);

console.log(unique); // ['a', 1, 2, '1']
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #JavaScript #remove #duplicate #items
ADD COMMENT
Topic
Name
5+5 =