Define call function in javascript

Possible duplicate:
How do I know the caller function in JavaScript?

How can I find out in a javascript function that was a call function (first on the call stack)?

I would like to determine if the first function called is __doPostback in the onbeforeunload event.

+3
source share
2 answers

Each function has a property caller.

From https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function/caller :

function myFunc() {
    if (myFunc.caller == null) {
        return ("The function was called from the top!");
    } else
        return ("This function caller was " + myFunc.caller);
    }
}

The property is Function.callernot part of the ECMA3 standard, but is implemented in all major browsers, including IE and Firefox.

, caller arguments.calee:

function() {
    if (arguments.callee.caller == null) {
        return ("The function was called from the top!");
    } else
        return ("This function caller was " + arguments.callee.caller);
    }
}

, , caller . deprecated arguments.caller, .

+15

chromeos cr-48 .callee.caller .

0

Source: https://habr.com/ru/post/1716081/


All Articles