Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

filter duplicates from array javascript

// usage example:
var myArray = ['a', 1, 'a', 2, '1'];
var unique = myArray.filter((v, i, a) => a.indexOf(v) === i);

console.log(unique); // unique is ['a', 1, 2, '1']
 Run code snippet
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #filter #duplicates #array #javascript
ADD COMMENT
Topic
Name
2+8 =