Understanding Javascript Closure

Closure is a nested function that has access to the variables in the outer (enclosing) function’s scope chain. It has access to variables in three scopes:

  • Variable in its own scope.
  • Variables in the enclosing (outer) function’s scope.
  • Global variables.

Best part of closure is that the nested (inner) function can access the variables from the outer scope even after the outer function has returned.


Leave a Reply

Your email address will not be published. Required fields are marked *