Quiz
- Can you give an example of the actual application of localstore a bit? lt is a bit abstract for me right now.
Sure. The final project of this course involves creating a "to do" list. There will be buttons to load/save the list to local storage, so that you can close your browser w/o losing the list.
- In the example of RPS game, is the first line "var wins, losses, ties;" set variables in local storage? Thank you!
No; it sets them as global variables in the browser tab. That's non-persistent (called "volatile") storage.
- Could we go over the json commands again?
Sure. JSON is the notation we've been learning all along:
- integers, floats, booleans, strings
- arrays:
[ val0, val1, val2, ... , val ]
- objects:
{key: val, key: val, ... key: val}
The
JSON.stringify()
function takes a data structure and turns it into a string.The
JSON.parse()
function takes a string and attempts to parse it into a data structure. - how can we handle data synchrony issues if the localStorage does get modified from a different browser tab having the same origin ? thankyou
Wow! That's a wonderful but very sophisticated question. I'm going to punt on it for now, but I encourage you to come talk to me in office hours.