133
rated 0 times
[
140]
[
7]
/ answers: 1 / hits: 32225
/ 9 Years ago, mon, september 7, 2015, 12:00:00
I have an array and i want to remove a record from it i have use Array.filter()
but its return same array as it is.
My Code:
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));
More From » jquery