Closures Flashcards

1
Q

In JavaScript, when is scope determined?

A

accessibility or visibility of variables

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

Closures allow us to remember values from their surrounding.

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

What values does a closure contain?

A

function bundled or enclosed with references to its surrounding state
any values referenced in the function

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

When is a closure created

A

every time a function is created, at function creation time

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

the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment)
anytime it references something

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

useEffect()

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