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.
Loading...
Related Quiz
- How can you handle errors in the fetch API when using async/await syntax?
- A do-while loop is particularly useful when you want to ensure the loop body executes at least ________ before checking the condition.
- The method _______ can be used to add new elements to the end of an array.
- To remove a child element, you should use the removeChild method on the _________ element.
- The arithmetic operator _______ increments the value of a variable by 1.