JavaScript Closure Flashcards
1
Q
In JavaScript, when is scope determined?
A
When the app renders
2
Q
What allows JavaScript functions to “remember” values from their surroundings?
A
closure
3
Q
What values does a closure contain?
A
variables within the scope when a function is created(in the parent function/container)
4
Q
When is a closure created?
A
when a function is created
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
6
Q
In React, what is one important case where you need to know if a closure was created?
A
Use Effects/dependencies