JavaScript & TypeScript

Closure

/ˈkləʊʒər/

Definition

A function that retains access to its outer scope's variables even after that scope has finished executing.

Example in context

"The callback is a closure — it captures userId from the outer function and still has access when it runs asynchronously."

Practice this term

Master Closure in context by working through exercises in the JavaScript & TypeScript module. You'll see the term used in real engineering scenarios with multiple-choice, fill-in-the-blank, and matching drills.