I keep array localstorage. I want to delete an element from the array list on another page. My code is below but delete function does not work why?
push.js
existingEntries = JSON.parse(localStorage.getItem("allEntries"));
if (existingEntries == null) existingEntries = [];
entry = {
"adi":path,
};
localStorage.setItem("entry", JSON.stringify(entry));
existingEntries.push(entry);
localStorage.setItem("allEntries", JSON.stringify(existingEntries));
delete.js
delete: function (e) {
var del = e.itemData.adi //The information of the clicked element is retrieved.
for (var i = 0; i < dataSource.length; i++) {
if (dataSource[i].adi == del) { dataSource.splice(i, 1); }
}
// insert the new stringified array into LocalStorage
localStorage.getItem("allEntries") =
JSON.stringify(existingEntries);
}