Skip to content

Instantly share code, notes, and snippets.

@Kamilnaja
Last active August 28, 2019 18:45
Show Gist options
  • Save Kamilnaja/0a922aa350da2e6f6f684137a69efc91 to your computer and use it in GitHub Desktop.
Save Kamilnaja/0a922aa350da2e6f6f684137a69efc91 to your computer and use it in GitHub Desktop.
// so, you have list of users like this
const users = [
{ id: '1', name: 'hello' },
{ id: '2', name: 'world' },
{ id: '3', name: 'hello' },
{ id: '1', name: 'hello' },
{ id: '1', name: 'hello' },
]
// as a result, we want to get list of users without duplicates, basing on id.
const res = [
{ id: '1', name: 'hello' },
{ id: '2', name: 'world' },
{ id: '3', name: 'hello' }
]
// I suggest you, not to use forEach or for methods.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment