Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function clearLocalStorage() {
- // if localStorage is already empty
- if (localStorage.length === 0) {
- // let the user know there is already nothing there
- alert('There is no data in localStorage to clear');
- } else { // if localStorage is not empty
- // make sure the user really wants to clear his localStorage
- if (window.confirm('Are you really sure you want to delete your entire localStorage')) {
- // clear local storage
- localStorage.clear();
- // display data again
- displayData();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement