Closure
Closure — A closure is a function that retains access to variables from its outer (enclosing) scope, even after the outer function has returned. A closure is created every time a function is defined inside another function. The inner function "closes over" the variables of the outer function, forming a closure. This is one of the most powerful features of JavaScript, enabling data privacy, partial application, and the module pattern. This term relates to the Function category of the reference. You will meet closure in practice when working with APIs such as Function.prototype.call(), Function.prototype.apply(), Function.prototype.bind(), Function.prototype.toString(). Related terms: Hoisting, Event Loop, Prototype Chain, Temporal Dead Zone (TDZ), IIFE (Immediately Invoked Function Expression), Currying. Understanding closure makes the rest of the JavaScript documentation noticeably easier to follow, because the concept recurs across methods, guides, and error messages. Look up more definitions in the JavaScript glossary.