In JavaScript, when a function is defined inside another function, the inner function has access to the ________ of the outer function due to lexical scoping.
- Variables
- Properties
- Methods
- Parameters
In JavaScript, when a function is defined inside another function, the inner function has access to the variables of the outer function due to lexical scoping. Lexical scoping means that the inner function "remembers" the scope in which it was created, allowing it to access and manipulate variables defined in the outer function. This behavior is one of the fundamental aspects of closures in JavaScript.
Loading...
Related Quiz
- In which scenario is a function expression preferred over a function declaration?
- Which design pattern can be used to create a family of related or dependent objects without specifying their concrete classes?
- In which scenario might you prefer to use Object.create(null) over {} to create an empty object?
- The mechanism that allows you to use the structure of a class and alter it for use in another class is known as _________.
- Which method returns a promise that resolves with the result of parsing the body text as JSON?