[size=medium]
If global variables are properties of the special global object, then what are local variables? They too are
properties of an object. This object is known as the call object . The call object has a shorter lifespan than
the global object, but it serves the same purpose. While the body of a function is executing, the function
arguments and local variables are stored as properties of this call object. The use of an entirely separate
object for local variables is what allows JavaScript to keep local variables from overwriting the value of
global variables with the same name.
[/size]
If global variables are properties of the special global object, then what are local variables? They too are
properties of an object. This object is known as the call object . The call object has a shorter lifespan than
the global object, but it serves the same purpose. While the body of a function is executing, the function
arguments and local variables are stored as properties of this call object. The use of an entirely separate
object for local variables is what allows JavaScript to keep local variables from overwriting the value of
global variables with the same name.
[/size]