JSON Flashcards

1
Q

What is JSON?

A

JSON (JavaScript Object Notation) is a text-based data format that follows JavaScript object syntax. It represents structured data as a string.

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

What are serialization and deserialization?

A

Serialization converts an object/array to a stream of bytes to store or send over a network.

Deserialization converts a stream of bytes to an object/array that can be used in a program.

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

Why are serialization and deserialization useful?

A

It allows objects to be saved, transferred, and recreated.

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

The .stringify() method on the JSON object.

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

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

A

The .parse() method of the JSON object.

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

By calling the .setItem() method of the localStorage object with two arguments: a string for the key and a JSON string for the value.

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

By calling the .getItem() method of the localStorage property with one argument: the string of the key.

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

The string data type.

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

Before the tab is closed or refreshed. Anything that would cause the application to reload or close.

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