home / experts / javascript / column80 |
|
Defining ContextsJavaScript distinguishes between three execution contexts: Global code, Eval code, and Function code. Contexts are different from each other in the set of variables that are defined in each context. Each time the browser enters a new context, it creates a new object that holds the new context's variables and functions. This object is called the variable object. Any variables or functions defined within a context, are loaded onto this variable object. The variable object is deleted whenever the browser exits an executing context. Therefore, all variables and functions that are local to an executing context are destroyed upon exiting the context. There is no way to access the variable object. When you access variables and functions, you actually access the variable object's parameters and methods. Global code is any code that is outside functions. Eval code is passed as a string to the When the browser switches a context, a new scope is determined. The scope determines which variables, objects, and functions are accessible from the execution context. For example, suppose a variable The scope is determined solely by the the variable object that is being created upon entering the new execution context, and destroyed upon leaving it. The variable object holds variables and functions that are currently active. The scope also includes the Next: How to classify scopes |
Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: March 26, 2001
Revised: March 26, 2001
URL: http://www.webreference.com/js/column80/5.html