localstoraage path js code example
Example 1: save to local storage
localStorage.setItem('myCat', 'Tom');
var cat = localStorage.getItem('myCat');
localStorage.removeItem('myCat');
localStorage.clear();
Example 2: local storage javascript
function createItem() {
localStorage.setItem('nameOfItem', 'value');
}
createItem()
function getValue() {
return localStorage.getItem('nameOfItem');
}
console.log(getValue());
Example 3: localStorage
var obj = {
firstName: "Bob",
lastName: "Jeff",
age: 13
}
localStorage.setItem("itemname", JSON.stringify(obj));
var item = JSON.parse(localStorage.getItem("itemname"));