A closure is an inner function that has access to the outer scope, even after the outer scope has executed.


Scope defines the lifetime and visibility of a variable.

Every time we create a function or a block {} , we create a new scope.

Variables declared with var have only function scope. Variables declared with let and const can have function and block scope.

A closure is a inner function. It has access to variables from the outer scopes.

Variables used by the closure function live as long as the closure lives.

Closures make it easy to work with async tasks like timers, events, AJAX calls.

Closures create encapsulation.

Discover Functional JavaScript was named one of the best new Functional Programming ebooks by BookAuthority!

For more on applying functional techniques to React take a look at Functional React.

Learn how to apply the Principles of Design Patterns.

You can find me on Medium and Twitter.