What is LocalStorage?

   JavaScript

The LocalStorage object stores data without expiry date in browser. The stored data will not be deleted when the browser is closed, and will always be available the next visit onwards. To delete the data, it needs to be cleared or removed manually. Below are few tasks which can be performed using LocalStorage:

Set Item

localStorage.setItem('seen', true); // Set Item

Get Item

localStorage.getItem('seen') // Get Item
// returns true

Remove Item

localStorage.removeItem('seen') // Remove Item

Clear All Items

localStorage.clear(); // Clear all items

Browser Support

Check Here for Browser Compatibility.

Tags: JavaScriptLocalStorage

Leave a Comment