JSON Flashcards
What is JSON?
JSON is a way to transmit data via a text-based format for representing structured data on JavaScript object syntax.
What are serializations and deserialization?
Serialization is the process of turning an object in memory into a stream of bytes so you can do stuff like store it on disk or send it over the network.
Deserialization is the reverse process: turning a stream of bytes into an object in memory.
Why are serialization and deserialization useful?
Gives us a way to transfer data to various devices and formats
How do you serialize a data structure into a JSON string using JavaScript?
JSON.stringify method
How do you deserialize a JSON string into a data structure using JavaScript?
JSON.parse method
How do you store data in localStorage?
localStorage.setItem(name, value)
How do you retrieve data from localStorage?
localStorage.getItem(name)
What data type can localStorage save in the browser?
string data specifically JSON strings
When does the ‘beforeunload’ event fire on the window object?
Before the page refreshes