Created
February 9, 2017 00:34
-
-
Save mLuby/18a2c66b244ca78d329efddd67ae087f to your computer and use it in GitHub Desktop.
one-liner to remove duplicate values from a list in JS. (immutable)
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
const dedup = list => list.reduce((uniques, item) => uniques.concat(uniques.includes(item) ? [] : [item]), []) | |
dedup(["a",2,"a",3,"b",2]) // ["a", 2, 3, "b"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment