You are debugging a JavaScript application, and you find a variable that seems to be available even after its block has finished executing. What concept of JavaScript allows this to happen?

  • Hoisting
  • Closure
  • Scope
  • Shadowing
This behavior is due to the concept of "Closure" in JavaScript. Closures allow functions to maintain access to their lexical scope, even after the outer function has completed execution. This enables the variable to persist and be accessible outside its block.
Add your answer
Loading...

Leave a comment

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