javascript save variable to local storage code example
Example 1: how to add variable to local storage in javascript
localStorage.setItem('key', 'value')
Example 2: js save local storage
localStorage.setItem('myCat', 'Tom');
var cat = localStorage.getItem("myCat");
localStorage.removeItem("lastname");
localStorage.clear();
Example 3: javascript save data to local storage
localStorage.lastname = "Smith";
document.getElementById("result").innerHTML = localStorage.lastname;
localStorage.removeItem("lastname");
Example 4: how to get data from localstorage in javascript
var data = JSON.parse(localStorage.getItem("key name"));