JSON Flashcards
What is JSON?
text-based data format following JavaScript object literal syntax
What are serialization and deserialization?
serialization: process of turning an object in memory into a stream of bytes
deserialization: turning a stream of bytes into an object in memory
Why are serialization and deserialization useful?
so you can do stuff like store it on disk or send it over the network
How do you serialize a data structure into a JSON string using JavaScript?
JSON.stringify( )
How do you deserialize a JSON string into a data structure using JavaScript?
JSON.parse( )
How to you store data in localStorage?
storage = window.localStorage
storage.setItem(‘key’, ‘value’ )
How to you retrieve data from localStorage?
.getItem( )
What data type can localStorage save in the browser?
strings
When does the ‘beforeunload’ event fire on the window object?
before the user tries to unload the page