JSON Flashcards

1
Q

What is JSON?

A

JavaScript Object Notation. It’s a standard text-based format for representing structured data based on JavaScript object syntax. This is commonly used for transmitting data in web applications.

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

What are serialization and deserialization?

A

Serialization is the process of converting an object in memory into a byte stream so that it can be stored on disk or transferred over the network. Deserialization is the inverse process of converting a stream of bytes into an object in memory.

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

Why are serialization and deserialization useful?

A

To save the state of an object in order to be able to recreate it when needed.

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

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

A

Using the JSON.stringify() method.

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

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

A

Using the JSON.parse() method.

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

How do you store data in localStorage?

A

Using the setItem() method.

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

How do you retrieve data from localStorage?

A

Using the getItem() method.

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

What data type can localStorage save in the browser?

A

Only strings.

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

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

A

The event is fired when the window, the document, and its resources are about to be unloaded, like refresh or close the window.

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