Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am charmedsatyr on github.
* I am charmedsatyr (https://keybase.io/charmedsatyr) on keybase.
* I have a public key ASAlfvhXnBEtxQECzQFYUMWRhL0wUBV1pvNmsRA9UXuMiAo
To claim this, I am signing this object:
@CharmedSatyr
CharmedSatyr / deduplicate_array.js
Last active July 28, 2018 00:00
Deduplicate Array
// METHOD 1: reduce/indexOf
//`uniques` contains one of each unique value in `arr`
let arr = ['ant', 0, 'aunt', 'ant'];
let uniques = arr.reduce((acc, curr) => {
if (acc.indexOf(curr) < 0) {
acc.push(curr);
}
return acc;
}, []);