There is such a JSON record of this type.

[{"name":"Книга1","price":"860","img":"KI_OBL_BOOK41.png"},{"name":"Книга2","price":"860","img":"OBL_BOOK41.png"},{"name":"Text1","price":"680","img":OBL_SBORNIK_NPA%20(8)mak.jpg"}]" 

Please tell {"name":"Книга2","price":"860","img":"OBL_BOOK41.png"} how to delete all the line {"name":"Книга2","price":"860","img":"OBL_BOOK41.png"} if there is Book2 in it, which matches the value from JSON

 var cookie = Cookies.get("book") re = new RegExp("Книга",'ig'); $.each(JSON.parse(cookie), function(i,e){ if(e.match(re) ) delete(e) }) 
  • create an empty array, go through the array in which you will look for matches, and if you do not find a match, then add the value to the empty array. - user190134
  • I rewrote the code, tell me where it’s wrong - Dunno
  • not right in removing items. you need to delete the i-th element from the array, and not the useless delete(e) to do. With this approach, by the way, you remove all relevant entries, not duplicates - teran

0