Skip to content

Instantly share code, notes, and snippets.

@Tusharbalar
Created December 4, 2017 12:17
Show Gist options
  • Save Tusharbalar/16379d502df868b4cc31b64aecdf0fbd to your computer and use it in GitHub Desktop.
Save Tusharbalar/16379d502df868b4cc31b64aecdf0fbd to your computer and use it in GitHub Desktop.
Remove an object from array by property
const initial = [ {id: 1, score: 1}, {id: 2, score: 2}, {id: 3, score: 4}]
const removeId = 3
const without3 = initial.filter(x => x.id !== removeId)
console.log(without3) // => [ { id: 1, score: 1 }, { id: 2, score: 2 } ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment