JavaScript Closure
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
Output:







