What is a closure?
Answer out loud or in your head first, then compare.
Answer
A closure means a function keeps access to the variables of the scope it was created in. It can use them later too, after the original function has finished.
For example, a function that creates a counter can return an increment function that still has access to its own count variable. That's useful for hiding state. In React, remember that a function created in a particular render uses the values from that render. That's why a timer can “remember” old state even though the screen already shows newer state.
Why it matters: It explains many problems with callbacks, timers and hooks.
Possible follow-ups: Why can a callback from the first render see stale state?
How did it go? Be honest — “Not yet” puts the question on your review list.
Related questions
- What is closure? — JavaScript
Further reading
- MDN: Closures(opens in a new tab)Accessed 22.10.2026. Closures and a function's access to its surrounding scope.