document.localstorage 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: localstorage js
localStorage.setItem('monChat', 'Tom');
localStorage.getItem('myCat');
localStorage.removeItem('myCat');
Example 3: local storage javascript
localStorage.setItem('user_name', 'Rohit');
var retrievedUsername = localStorage.getItem('user_name');
Example 4: localstorage
var cat = localStorage.getItem('myCat');
Example 5: localstorage javascript
localStorage.setItem("lastname", "Smith");
document.getElementById("result").innerHTML = localStorage.getItem("lastname");