Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I just remove data in localStorage by its key?

I am learning about HTML5 these days.

Here comes trouble when I want to remove just one of the data in the localStorage.

I know a method called clear() to remove anything, but what can I do if I just remove one of the data by its key?

like image 388
willnew Avatar asked Feb 13 '12 07:02

willnew


People also ask

How do I remove data from localStorage in react?

removeItem("data") With localStorage. removeItem('data') we can remove the localStorage item. Its use case is similar to setItem() – when we want to remove an item, we click a button to complete that functionality.


1 Answers

sessionStorage.removeItem('UserName');
localStorage.removeItem('UserName');
like image 141
Muhammad Liaquat Avatar answered Oct 07 '22 15:10

Muhammad Liaquat