store localstorage 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: local storage javascript
localStorage.setItem('user_name', 'Rohit');
var retrievedUsername = localStorage.getItem('user_name');
Example 3: setlocalstorage
localStorage.setItem('data', JSON.stringify(arryName));
Example 4: javascript localstorage
var KeyName = window.localStorage.key(index);