Storing a Value
localStorage.setItem("key1", "value1");
Getting a Value
//this will print the value
alert(localStorage.getItem("key1"));
Removing a Value
localStorage.removeItem("key1");
Removing All Values
localStorage.clear();
Note:
The same syntax applies to the session storage, with one difference: Instead of localStorage, sessionStorage is used
by Valeri Tandilashvili
4 years ago
JavaScript
2
Pro tip: use ```triple backticks around text``` to write in code fences