javascript localstorage how to use code example
Example 1: javascript store object in local storage
var person = { "name": "billy", "age": 23};
localStorage.setItem('person', JSON.stringify(person));
var retrievedPerson = JSON.parse(localStorage.getItem('person'));
Example 2: javascript localstorage
localStorage.setItem("user_name", "Bob");
document.body.addEventListener("click", function(){
alert(localStorage.getItem("user_name"))
});
Example 3: js local storage
myStorage = localStorage;
localStorage.setItem('myCat', 'Tom');
var cat = localStorage.getItem('myCat');
localStorage.removeItem('myCat');
localStorage.clear();