Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var name = localStorage.username; // Query a stored value.
- name = localStorage["username"]; // Array notation equivalent
- if (!name) {
- name = prompt("What is your name?"); // Ask the user a question.
- localStorage.username = name; // Store the user's response.
- }
- // Iterate through all stored name/value pairs
- for(var name in localStorage) { // Iterate all stored names
- var value = localStorage[name]; // Look up the value of each one
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement