I have an cart array into which I am pushing the elements like:
cart = [];
this.cart.push(item);
I also want to delete the element from this cart[]
array based on id, the objects structure looks like:
[
{
id:1,
imageUrl: "http://lorempixel.com/100/100/people?1",
author: "Windward",
handle: "@windwardstudios",
body: "Looking for a better company reporting or docgen app?",
totalLikes: 0,
iLike: false
},
{
id:2,
imageUrl: "http://lorempixel.com/100/100/people?1",
author: "Windward",
handle: "@windwardstudios",
body: "Looking for a better company reporting or docgen app?",
totalLikes: 0,
iLike: false
}
]
I'm doing the pop
operation to remove the object that is added to array, but unfortunately this is removing the last inserted item. Which I don't want.
this.cart.pop();
How can I do this in typescript?