An execution context is the environment within which a portion of script code executes. If subsequent fragments of code are called, they are assembled to form a stack of execution contexts such that when one exits, the stack is popped and control returns to the immediate parent or caller.
The first item to be placed on the stack is the initial code that is considered to be global and is executed in a web browser as the page is parsed. Other types of host implementation may execute this global code at a different time. The topmost item on the stack is the code fragment that is currently executing. This might be the code in a called function or some code that is triggered by an event and is running as the handler for it.
Every execution context has associated with it its own variable object in which functions, formal parameters and variables are maintained as properties.
Each execution context also has its own private scope chain, which is a logical list of objects that are searched when name binding an identifier.
As the flow of control enters each execution context, its scope chain is created and initialized, variable instantiation is performed creating the variable object which in turn causes the arguments object to be created as well. At this time the this value is also determined The particular values for these items depend on the kind of code being entered.
|See also:||Activation object, Anonymous code, argc parameter, Arguments object, argv parameter, Eval code, Executable code, Function code, Function object, Function.arguments, Global code, Global object, Identifier resolution, Implementation-supplied code, main() function, Primary expression, Scope chain, this, Variable instantiation|