JavaScript JSON and Local Storage Flashcards
What is JSON?
JavaScript Object Notation
Data interchange format used to send and store information in computer systems. Saves data after the web page has been closed
What are serialization and deserialization?
Serialization converting a native object to a string so it can be transmitted across a network
Deserialization is converting a string to a native object
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 do you store data in localStorage?
localStorage.setItem();
You call the setItem method of the localStorage object with keyName and keyValue
How do you retrieve data from localStorage?
localStorage.getItem();
You call the getItem method of the localStorage object with the keyName
What data type can localStorage save in the browser?
strings
When does the ‘beforeunload’ event fire on the window object?
When the page is refreshed or closed