create local storage in 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: how to get variable in local storage in javascript
localStorage.getItem('id');
Example 3: setlocalstorage
localStorage.setItem('data', JSON.stringify(arryName));
Example 4: js local storage
myStorage = localStorage;
localStorage.setItem('myCat', 'Tom');
var cat = localStorage.getItem('myCat');
localStorage.removeItem('myCat');
localStorage.clear();