JavaScript Closure Flashcards

1
Q

In JavaScript, when is scope determined?

A

When the app renders

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

What allows JavaScript functions to “remember” values from their surroundings?

A

closure

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

What values does a closure contain?

A

variables within the scope when a function is created(in the parent function/container)

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

When is a closure created?

A

when a function is created

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

How can you tell if a function will be created as a closure?

A

nested function that needs a variable outside of its scope

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

In React, what is one important case where you need to know if a closure was created?

A

Use Effects/dependencies

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