How to clear localStorage when browser/tab is closing code example
Example: How to clear localStorage when browser/tab is closing
window.addEventListener("beforeunload", () => localStorage.removeItem('storageVariable'));
window.addEventListener("beforeunload", () => localStorage.removeItem('storageVariable'));