Closure
Definition
A function that retains access to variables from its outer (enclosing) scope even after the outer function has returned. Closures are created every time a function is created in JavaScript.
Code Example
Javascript
Tip: Modify the code above and click “Run” to see the results
Learn More
Related Terms
Scope
The region of code where a variable is accessible. JavaScript has global scope, function scope, and block scope. Block scope was introduced with let and const in ES6.
Higher-Order FunctionA function that either takes one or more functions as arguments, returns a function, or both. Common examples include map, filter, reduce, and forEach.
IIFEImmediately Invoked Function Expression — a function that runs immediately after being defined. IIFEs create a private scope and are used to avoid polluting the global namespace.