Skip to content

Instantly share code, notes, and snippets.

@mLuby
Created February 9, 2017 00:34
Show Gist options
  • Save mLuby/18a2c66b244ca78d329efddd67ae087f to your computer and use it in GitHub Desktop.
Save mLuby/18a2c66b244ca78d329efddd67ae087f to your computer and use it in GitHub Desktop.
one-liner to remove duplicate values from a list in JS. (immutable)
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