JavaScript Category
CLOSURE
Function with preserved outer scope access.
Definition
A closure is created when a function keeps access to variables from the scope where it was defined, even after that outer scope has finished executing.
Practical Example & Use Case
A UI module can create one event handler factory that closes over a specific feature flag, so each generated handler behaves differently without global state.
Editorial review date: 2026-03-10