Web Storage API part 3

Web Storage API
38
3/3













Working with Values
The syntax for web storage for both local and session storage is very simple and similar.
The data is stored as key/value pairs.
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();
The same syntax applies to the session storage, with one difference: Instead of localStorage, sessionStorage is used.
Comments
Post a Comment