local storage and session storage javascript code example
Example 1: how to set session storage in javascript
sessionStorage.setItem('key', 'value');
let data = sessionStorage.getItem('key');
sessionStorage.removeItem('key');
sessionStorage.clear();
Example 2: javascript save data to local storage
localStorage.lastname = "Smith";
document.getElementById("result").innerHTML = localStorage.lastname;
localStorage.removeItem("lastname");
Example 3: what is local storage and session storage in javascript