accessing local storage javascript code example
Example 1: local storage javascript
function createItem() {
localStorage.setItem('nameOfItem', 'value');
}
createItem()
function getValue() {
return localStorage.getItem('nameOfItem');
}
console.log(getValue());
Example 2: js local storage
myStorage = localStorage;
localStorage.setItem('myCat', 'Tom');
var cat = localStorage.getItem('myCat');
localStorage.removeItem('myCat');
localStorage.clear();
Example 3: localstorage
localStorage.setItem('myCat', 'Tom');
Example 4: localstorage
localStorage.removeItem('myCat');