[javascript] 변수 객체(variable object)란 무엇인가?
When a function is invoked, a new execution context is created, and within this context, the variable object is created and contains the following:
- The function’s arguments object
- The function’s parameters as named properties
- The function declarations
- Any variables declared with the
var
keyword
The variable object forms the foundation for executing the function’s code within its scope.
For example, in the code below, when the foo
function is invoked, a new execution context is created, and its variable object will hold the variables a
, b
, and the function declaration bar
.
function foo(a) {
var b = 2;
function bar() {
// function code
}
// function code
}
Understanding the variable object is essential for understanding how JavaScript manages scope and how variables and functions are accessed during execution.
For more detailed information, you can refer to the JavaScript specification on Execution Contexts and Variable Objects (ECMAScript 5.1, Section 10.3).