Global code is any code that is outside functions. Eval code is passed as a string to the
eval() function (
eval(alert("bla bla bla")). Function code is code within a function definition.
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
a is defined in both the main program and inside the function
foo(). If the variable
a is incremented inside the function
a is being incremented, the one defined inside
foo(), or the one defined in the main code?
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
this object. When you refer to
this, which object are you referring to?
Next: How to classify scopes