How can I remove an object from an array?
I wish to remove the object that includes name Kristian from someArray. For example:
someArray = [{name:"Kristian", lines:"2,5,10"},
{name:"John", lines:"1,19,26,96"}];
I want to achieve:
someArray = [{name:"John", lines:"1,19,26,96"}];
You can use several methods to remove item(s) from an Array:
If you want to remove element at position
x, use:Or
Reply to the comment of @chill182: you can remove one or more elements from an array using
Array.filter, orArray.splicecombined withArray.findIndex(see MDN).See this Stackblitz project or the snippet below: