Now this is all very nice, but what if you want to store something more complicated than a simple string? What if you want to parse some data from valpal.info/languages/ainu/coding_frames/4895372581 and then save it to localStorage
, but it’s an array of objects, not just a string?
Simple: you JSON.stringify
it, and store that. Then, when you want the data out again, you get it out of localStorage
, and JSON.parse
it, and voilà, it’s an array of objects again.
localStorage.ainu = JSON.stringify({"someStuff": "about ainu"})
Let’s say you ran that on the link above. Well, it’s in localStorage
now. If you go to another coding page anywhere on valpal.org, like, say, http://valpal.info/languages/zenzontepec-chatino/coding_frames/5993124311, then localStorage
still contains your stringified Ainu object. You could run the same code, and then save that as localStorage.zenzontepec = JSON.stringify({"someChatino": "stuff"})
.
There’s more. But I gotta go.