Last active
June 12, 2018 21:14
-
-
Save mattbontrager/d71bf584897643f9422567681f6ab341 to your computer and use it in GitHub Desktop.
Easily store unique values from an array with multiples of those values.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var distinctValues = ['one', 'two', 'three', 'four', 'five', 'two', 'one', 'three', 'three', 'four'].filter((val, idx, me) => { | |
return me.indexOf(val) === idx; | |
}); | |
console.log(distinctValues); | |
// ['one', 'two', 'three', 'four', 'five']; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment