localStorage.setItem("key1", "value1");
Getting a Value//this will print the value
alert(localStorage.getItem("key1"));
Removing a ValuelocalStorage.removeItem("key1");
Removing All ValueslocalStorage.clear();
Note: The same syntax applies to the session storage, with one difference: Instead of localStorage, sessionStorage is used