Created
March 21, 2019 17:24
-
-
Save valeriocs/780c033be19959a587779b46605c82da to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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