
A closure is a function that remembers the variables from its outer scope even after the outer function has finished running. This happens automatically in JavaScript. Closures are used to create private variables, build factory functions, and maintain state in callbacks. Understanding closures is the key to understanding how JavaScript truly works.
Reference:
TaskLoco™ — The Sticky Note GOAT