1localStorage.setItem('user_name', 'Rohit'); //store a key/value
2var retrievedUsername = localStorage.getItem('user_name'); //retrieve the key
1localStorage.setItem("user_name", "Bob");
2
3document.body.addEventListener("click", function(){
4 alert(localStorage.getItem("user_name"))
5});
1var data = JSON.parse(/*previously copied stringified JSON from clipboard*/);
2Object.keys(data).forEach(function (k) {
3 localStorage.setItem(k, data[k]);
4});