Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove Objects From Array By Object Property
// Source: http://stackoverflow.com/questions/16491758/remove-objects-from-array-by-object-property
var arr = [
{
id: 1,
property: "Property",
},
{
id:2,
property: "Property",
}
];
// Get the index of the Array for object with id corresponding to 2:
var removeIndex = arr.map((element) => { return item.id; }).indexOf(2);
// Remove Object from Array:
arr.splice(removeIndex, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment