javascript - how to remove element from session storage array when there are lot of -
i trying remove elements localstorage array. find localstorage.removeitem(key);
i couldn't understand how works because have 2 sessionstorage. okay?
i have far
var thecart = json.parse(sessionstorage.getitem("productname")); // retrieving var quantity = json.parse(sessionstorage.getitem("quantityofprod")); var prodprice = json.parse(sessionstorage.getitem("sum"));
productname, quantityofprod , sum arrays. don't how form localstorage.removeitem select array , select element inside array. have tried
sessionstorage.removeitem("productname", json.stringify(namee));
namee variable contains element want delete inside specific sessionstorage array. doing deleting everything.
you have way:
- read entry
- decode json
- remove element
- encode json
update entry
tmp = json.parse(sessionstorage.getitem("productname")); delete tmp["key remove"]; sessionstorage.setitem("productname", json.stringify(tmp));
done.
Comments
Post a Comment