Closures Flashcards
In JavaScript, when is scope determined?
accessibility or visibility of variables
What allows JavaScript functions to “remember” values from their surroundings?
Closures allow us to remember values from their surrounding.
What values does a closure contain?
function bundled or enclosed with references to its surrounding state
any values referenced in the function
When is a closure created
every time a function is created, at function creation time
How can you tell if a function will be created as a closure?
the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment)
anytime it references something
In React, what is one important case where you need to know if a closure was created?
useEffect()