Sitemap

JavaScript Closure

Sep 3, 2024

A closure in JavaScript is a function that remembers the environment in which it was created. In other words, it has access to variables from its own scope, the outer function’s scope, and the global scope.

We can access the outer function’s properties and variables from within the inner function, but the outer function cannot access the inner function’s properties or variables

Get Dhileep’s stories in your inbox

Join Medium for free to get updates from this writer.

Example

Press enter or click to view image in full size

Output: