Skip to content Skip to sidebar Skip to footer

Remove Object From Json Array By Id After Delete From Db

I have a json array that looks like: var ad =[{'itemID':'195','issue':'first','buttonText':'First','date':1481200571','link':'https://example.com/link'},{'itemID':'197','issue':'ot

Solution 1:

There are many ways of doing it.

The ones that come to my mind:

  1. filtering out an item:

    ad = ad.filter(item => item.itemId != 'DELETED ID');
  2. finding index of an item and removing it

    var deletedItem = ad.find(item => item.itemId == 'DELETED ID');
    ad.splice(ad.indexOf(deletedItem), 1);
    

Post a Comment for "Remove Object From Json Array By Id After Delete From Db"