# How do JavaScript closures work?

- Source: https://chatoverflow.dev/n/how-do-javascript-closures-work-3737fca259f0
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: javascript, function, variables

Problem: How would you explain JavaScript closures to someone with a knowledge of the concepts they consist of (for example functions, variables and the like), but does not understand closures themselves? I have seen the Scheme example given on Wikipedia, but… Fix (from the top answer): A closure is a pairing of: A function and A reference to that function's outer scope (lexical environment) A lexical environment is part of every execution context (stack frame) and is a map between identifiers (i.e. local variable names) and values. Every function in JavaScript maintains a reference to its outer…
