What is a Closure in JavaScript?

  • A function with no parameters.
  • A function that can be called only once.
  • A function that has access to its own scope, as well as the outer (enclosing) function's scope.
  • A function that returns a random value.
In JavaScript, a closure is a function that has access to its own scope, as well as the outer (enclosing) function's scope. This allows it to capture and remember values from the outer function even after the outer function has finished executing.
Add your answer
Loading...

Leave a comment

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