JavaScript Call Object

Navigation Aids -- This Page        Navigation Aids -- This Topic        Navigation Aids -- This Site

Introduction And Review

JavaScript has two special objects that help with function processing. These are the:

These two objects work together and have some common characteristics:

The Call Object Description

The Call Object is a special temporary object that exists while a function is active. The Call Object has two main purposes:

  1. Provide a pointer to the Arguments Object
  2. Administer the Scope Chain during function processing

The Call Object has no other properties or features.

The Pointer to the Arguments Object

The Call Object contains a property that serves as a pointer to the Arguments Object. This property is the arguments property. The arguments property serves as a means to access the properties of the Arguments Object.

Why does JavaScript place the arguments property with the Call Object? There are two reasons.

  1. The Arguments Object is not a native object that can be named or instantiated. There is no native way to access the properties of the Arguments Object. So, JavaScript provides a pointer (property) in the Call Object that points to the Arguments Object. Remember that both the Call Object and the Arguments Object are spawned together simultaneously when the function is invoked and both vanish when the function finishes execution. They act as partners in the JavaScript scheme for the function processing.
  2. The arguments property needs to be inserted onto the scope chain along with the rest of the function's local variables. This assures proper access to the appropriate Arguments Object when function nesting occurs.

Administer the Scope Chain

The Call Object helps to represent a function once the function has been invoked. The Call Object exists temporarily until the invoked function has finished execution. While the function is active, the call object will place the following on to the scope chain:

All of the above become properties of the Call Object. The Call Object operates in conjunction with the Global Object. All global variables are properties of the Global Object. At the time of page initialization, the Global Object places global variables on to the scope chain. The purpose of the Call Object is to place local variables ahead of global variables in the scope chain. Once the function is done executing, the temporary local variables are removed from the scope chain and the permanent global variables move to the top of the chain. The use of an entirely different object for local variables allows JavaScript to keep local variables from overriding the global variable values when both local and global variables have the same name. Where functions exist in a nesting structure, each function has its own Call Object.

In summary, when two variables have the same name, the integrity of the scope chain is maintained:


Rx4AJAX        About Us | Topic Index | Contact Us | Privacy Policy | 2008 This Site Built By PPThompson