Export (0) Print
Expand All
3 out of 3 rated this helpful - Rate this topic

caller Property (Function) (JavaScript)

Gets the function that invoked the current function.

functionName.caller

The functionName object is the name of any executing function.

The caller property is defined for a function only 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:

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

document.write(CallLevel());

// Output: CallLevel was called from the top level.

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, Internet Explorer 11 standards. Also supported Store apps (Windows 8 and Windows Phone 8.1). See Version Information.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.