Answers for "javascript clear localstorage on browser close"

5

javascript clear localstorage

window.localStorage.clear(); //clear all localstorage
window.localStorage.removeItem("my_item_key"); //remove one item
Posted by: Guest on July-31-2019
1

How to clear localStorage when browser/tab is closing

window.addEventListener("beforeunload", () => localStorage.removeItem('storageVariable'));
Posted by: Guest on July-25-2020

Code answers related to "javascript clear localstorage on browser close"

Code answers related to "Javascript"

Browse Popular Code Answers by Language