First-Class Functions, Closures & Lexical Scope
Master first-class function assignments, higher-order functions, lexical scope environments, and private state encapsulation using Closures.
Lexical Environment & Closure Encapsulation
### What is a Closure?
A **Closure** is the combination of a function bundled together with references to its surrounding **lexical environment**. In JavaScript, closures allow an inner function to retain access to variables declared in its outer scope even after the outer function has returned.
Closures enable module patterns, private instance variable encapsulation, currying, and memoization caching.