JavaScript JSON and Local Storage Flashcards

1
Q

What is JSON?

A

JavaScript Object Notation

Data interchange format used to send and store information in computer systems. Saves data after the web page has been closed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are serialization and deserialization?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you serialize a data structure into a JSON string using JavaScript?

A

JSON.stringify();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you deserialize a JSON string into a data structure using JavaScript?

A

JSON.parse();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you store data in localStorage?

A

localStorage.setItem();

You call the setItem method of the localStorage object with keyName and keyValue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you retrieve data from localStorage?

A

localStorage.getItem();

You call the getItem method of the localStorage object with the keyName

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What data type can localStorage save in the browser?

A

strings

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When does the ‘beforeunload’ event fire on the window object?

A

When the page is refreshed or closed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly