caller Property (JavaScript)

Switch View :
ScriptFree
JavaScript
caller Property (JavaScript)

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Returns a reference to the function that invoked the current function.

functionName.caller
Remarks

The functionName object is the name of any executing function.

The caller property is only defined for a function while that function is executing. If the function is called from the top level of a JavaScript program, caller contains null.

If the caller property is used in a string context, the result is the same as functionName.toString, that is, the decompiled text of the function is displayed.

The following example illustrates the use of the caller property:

JavaScript
function CallLevel(){
   if (CallLevel.caller == null)
      return("CallLevel was called from the top level.");
   else
      return("CallLevel was called by another function.");
}
Requirements

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards. Also supported in Metro style apps. See Version Information.

Applies To: Function Object (JavaScript)

See Also

Reference