I have an array and I want to remove the entry from it. I use Array.filter() , but it returns the same array as it.
My code is:
var url = window.location.pathname, orderId = url.split('/').slice(-2)[0]; var Cart = JSON.parse(localStorage.getItem('Cart')); newCart=Cart.filter(function(item) { if (parseInt(item.orderId) == parseInt(orderId)) { return {}; } else { return item; } }); localStorage.setItem('Cart',JSON.stringify(newCart));
javascript jquery arrays
user4069483
source share