Skip to content

Instantly share code, notes, and snippets.

@mattbontrager
Last active June 12, 2018 21:14
Show Gist options
  • Save mattbontrager/d71bf584897643f9422567681f6ab341 to your computer and use it in GitHub Desktop.
Save mattbontrager/d71bf584897643f9422567681f6ab341 to your computer and use it in GitHub Desktop.
Easily store unique values from an array with multiples of those values.
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