Skip to content

Instantly share code, notes, and snippets.

@framp
Created May 3, 2016 13:58
Show Gist options
  • Select an option

  • Save framp/0ec26fb9f0cba348c791d13063f34bff to your computer and use it in GitHub Desktop.

Select an option

Save framp/0ec26fb9f0cba348c791d13063f34bff to your computer and use it in GitHub Desktop.
unique by function
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