Java Reference
In-Depth Information
if(window.localStorage) {
localStorage.setItem(name, "Walter White");
}
This will illustrate that it's being saved locally. Try completely closing your browser, re-
opening the console, and entering the same line of code:
if(window.localStorage) {
localStorage.getItem(name);
}
<< "Walter White"
To remove an entry from local storage use the removeItem method:
if(localStorage.name) {
localStorage.removeItem(name);
}
Alternatively, this can be done by simply using assignment:
if(window.localStorage) {
localStorage.name = "Jesse Pinkman";
}
if(window.localStorage) {
console.log(localStorage.name);
}
<< "Jesse Pinkman";
if(window.localStorage) {
delete localStorage.name;
}
To completely remove everything stored in local storage, use the clear() method:
Search WWH ::




Custom Search