Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearing localStorage in javascript?

Is there any way to reset/clear browser's localStorage in javascript?

like image 271
Bnicholas Avatar asked Oct 05 '11 21:10

Bnicholas


People also ask

What is localStorage clear ()?

The clear() method removes all the Storage Object item for this domain. The clear() method belongs to the Storage Object, which can be either a localStorage object or a sessionStorrage object.

How clear local storage data react JS?

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.

How do I clear a specific key in localStorage?

removeItem() The removeItem() method of the Storage interface, when passed a key name, will remove that key from the given Storage object if it exists.


1 Answers

Use this to clear localStorage:

localStorage.clear(); 
like image 139
Digital Plane Avatar answered Sep 19 '22 04:09

Digital Plane