javascript-local-storage Flashcards

1
Q

How do you store data in localStorage?

A

To store data in localStorage use: localStorage.setItem(‘name’, stringified data variable);

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

How do you retrieve data from localStorage?

A

To retrieve data from localStorage use: localStorage.getItem(string name);

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

What data type can localStorage save in the browser?

A

The data type that localStorage can save in the browser is a string.

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

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

A

The ‘beforeunload’ event fires right before the page closes or refreshes, while everything is still loaded into the browser and document. The preventDefault() method will have the website ask the user if it is okay to leave the page.

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