Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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']
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #remove #duplicates #array #javascript
ADD COMMENT
Topic
Name
5+2 =