How to remove and clear all localStorage data [duplicate]

I need to clear all data i set into localStorage. By this, I mean completely reset localStorage to null when users remove their accounts.

How can i do that with a simple function?

I tried this:

function clearLocalStorage(){
    return localStorage= null;
}

But it doesn’t work as expected.

5 Answers
5

Leave a Comment