Skip to content

Instantly share code, notes, and snippets.

@valeriocs
Created March 21, 2019 17:24
Show Gist options
  • Save valeriocs/780c033be19959a587779b46605c82da to your computer and use it in GitHub Desktop.
Save valeriocs/780c033be19959a587779b46605c82da to your computer and use it in GitHub Desktop.
getUnique(arr, comp) {
const unique = arr
.map(e => e[comp])
// store the keys of the unique objects
.map((e, i, final) => final.indexOf(e) === i && i)
// eliminate the dead keys & store unique objects
.filter(e => arr[e]).map(e => arr[e]);
return unique;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment