Local Storage in Javascript | HTML5 web storage API
Local Storage
Local Storage is used to store websites data locally on a device. Basically LocalStorage is not a database. LocalStorage provide 5MB of space on user computer. It is use for saving passwords, name, email etc.
LocalStorage.setItem
The localStorage.setItem is use to set data into localStorage. It can be write as :
localStorage.setItem(key, data) ;
So the localStorage.setItem has two parameters. The first one use for the key and the second ine use for the data to be store in the localstorage. The key should be in the string.
var data = 12;
localStorage.setItem("keyName", data) ;
localStorage.getItem
The localStorage.getItem is use to get the data from the localStorage.
localStorage.getItem(key);
The localStorage.getItem has only one parameter which is the key. The key of localStorage.getItem should be string.
var data = localStorage.getItem("keyName") ;
Comments
Post a Comment