1var person = { "name": "billy", "age": 23};
2
3localStorage.setItem('person', JSON.stringify(person)); //stringify object and store
4var retrievedPerson = JSON.parse(localStorage.getItem('person')); //retrieve the object
1localStorage.setItem('user_name', 'Rohit'); //store a key/value
2var retrievedUsername = localStorage.getItem('user_name'); //retrieve the key
1localStorage.setItem(key, val);
2var val = localStorage.getItem(key);
3localStorage.removeItem(key);
4localStorage.clear();