Software Engineering ยท Design
A function that captures and 'remembers' variables from the scope it was defined in, even after that scope has finished executing.
Example: A counter factory that returns a function with its own private count variable โ each call to the factory produces a counter that doesn't share state with others.
In practice: Closures are how private state is achieved in languages without access modifiers (like JavaScript) and how callbacks 'remember' context. Memory leaks from unintentional closures holding references are a real gotcha.