The localStorage read-only property of the window interface allows you to access a storage object for the document’s origin. The data which persists in the browser with no expiry date.

Set Value

To add any data to the local storage, use setItem(). The key & value should be a string.

localStorage.setItem('key', 'value');

Get Value

To retrieved the value of a particular key, use getItem().

localStorage.getItem('key');

Remove Value

To remove the data of a particular key.

localStorage.removeItem('key');

Clear all Values

To clear all local storage.

localStorage.clear();

That’s it in this #quick KB.
Thank you for reading. Happy Coding..!!

Leave a Reply