JSON Flashcards
What is a JSON?
JavaScript Object Notation: data exchange format that is a string that resembles a string.
What is serialization and deserialization?
Serialization: turning object in memory to s stream of bytes
Deserialization: turning a stream of bytes back to an object in memory
Why are serialization and deserialization useful?
to help with the transfer of data
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?
localStorage.setItem(key,value)
How do you retrieve data from localStorage?
localStorage.getItem(key)
What data type can localStorage save in the browser?
JSON String
When does the ‘beforeunload’ event fire on the window object?
before the window unloads
When to user ‘beforeunload’
to store the data from the localStorage