Skip to content

Instantly share code, notes, and snippets.

@davidicus
Created December 25, 2017 20:51
Show Gist options
  • Save davidicus/3fbdbd3f32c520a9cae01918c617660d to your computer and use it in GitHub Desktop.
Save davidicus/3fbdbd3f32c520a9cae01918c617660d to your computer and use it in GitHub Desktop.
Remove duplicate values in an array
const myArray = [0, 1, 1, 2, 3, 3]
myArray.reduce((a, b) => {
if (a.indexOf(b) < 0) {
a.push(b);
}
return a;
}, []);
// returns [0,1,2,3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment