localStorage in Javascript

Share Button


localStorage is used in javascript for storing data in clients side i.e. in the browser of user. There is no expiration time in localStorage that means the data stored in localStorage will not destroyed after closing or restarting the browser.



For storing data in localStorage use this syntax

localStorage.setItem('something', 'Daves');

For getting this stored data use this syntax


For deleting an specific item from localstorage use this


For deleting all localstorage data use this


Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
localStorage 4 3.5 8 10.50 4
sessionStorage 5 2 8 10.50 4
Share Button