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:

  1. read entry
  2. decode json
  3. remove element
  4. encode json
  5. update entry

    tmp = json.parse(sessionstorage.getitem("productname")); delete tmp["key remove"]; sessionstorage.setitem("productname", json.stringify(tmp)); 

done.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -