Caller Property (function) (JavaScript)

Source: Internet
Author: User

Reprint: http://msdn.microsoft.com/zh-cn/library/7t96kt3h (v=vs.94). aspx

Gets the function that invokes the current function.

Functionname.caller

Note

The FunctionName object is the name of any function that is executing.

caller   property is defined only when the function is executing.  null. " If the function is called from the top level of the JavaScript program, then   caller   contains   null.

If the caller property is used in the context of a string, its result and functionname. ToString is the same, that is, the anti-compilation text of the function is displayed.

The following example illustrates the use of the caller property:

1 functionCalllevel () {2    if(Calllevel.caller = =NULL)3       return("Calllevel is called from the top level.");4    Else5       return("Calllevel is called by another function.");6 }7 8 document.write (Calllevel ());9 Ten //Output:calllevel is called from the top level.

Requirements

Supported in the following document modes: Quirks, Internet Explorer 6 standard mode, Internet Explorer 7 Standard mode, Internet Explorer 8 standard mode, Internet Explorer 9 standard mode, INT Ernet Explorer 10 Standard mode and Internet Explorer 11 standard mode. In addition, it is also supported in store apps (Windows 8 and Windows Phone 8.1).

Caller Property (function) (JavaScript)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.