I have populated the sessionStorage in the following way
var shopcart = [];
if (!itemincart) {
shopcart.push(iteminfo);
}
sessionStorage["sca"] = JSON.stringify(shopcart);
And now I want to make the sessionStorage completely empty. I have tried several suggestions on this site but could not find any solution till now. Any help will be appreciated.
You can use
sessionStorage.clear();to remove all the data set insessionStorageor usesessionStorage.removeItem();to remove just one item in thesessionStorage:or:
You can read more about this here.
UPDATE:
If you mean you want to clear the
sessionStorage[]array, then you can do it by setting it to a new empty array like this: