Created
May 3, 2016 13:58
-
-
Save framp/0ec26fb9f0cba348c791d13063f34bff to your computer and use it in GitHub Desktop.
unique by function
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
| const users = [{userId:"34"},{userId: "10"}, {userId: "1"}, {userId: "1"}] | |
| const sameUserId = (a, i) => (b, j) => a.userId === b.userId && j>i | |
| users.filter((value, index, array) => array.findIndex(sameUserId(value, index)) < 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment