MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/71rrg4/essential_vanilla_javascript_functions/dnd8lkl/?context=3
r/javascript • u/bhalp1 • Sep 22 '17
19 comments sorted by
View all comments
4
For simple arrays you can dedupe with:
const arrayUnique = arr => [...new Set(arr)];
1 u/tencircles Sep 22 '17 you could also do:const uniq = a => a.filter((x, i, s) => s.indexOf(x) === i);May be more performance depending on implementation.
1
you could also do:
const uniq = a => a.filter((x, i, s) => s.indexOf(x) === i);
May be more performance depending on implementation.
4
u/adregan Sep 22 '17
For simple arrays you can dedupe with: