I have tried the below code to delete last added array(Users array)object.It works in console.but it doesnt delete the data from localstorage.Any help would be appreciated
var delRecord = JSON.parse(localStorage.getItem("MyRecords"));
for (var d = 0; d < delRecord .length; d++) {
delRecord [d].Users.pop();
}
Is pop() method will work or any suggestions?
You need to write the result back to the local storage:
var delRecord = JSON.parse(localStorage.getItem("MyRecords"));
for (var d = 0; d < delRecord .length; d++) {
delRecord[d].Users.pop();
}
localStorage.setItem("MyRecords", JSON.stringify(delRecord));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.