1

I am trying to get the name of a function which called the current function in jquery.

For example, say there are three functions

function a, function b, function c

and when one of those functions call function z, i would like to be able to get a string output of the function that called function z if that is possible please?

0

2 Answers 2

3

Javascript provides a mechanism for accessing the current function's callee:

function FunctionA() {
    alert(arguments.callee.caller.name);
}

function FunctionB() {
    FunctionA();
}

FunctionB();

The following JSFiddle demonstrates this, too. http://jsfiddle.net/8UFe2/

Sign up to request clarification or add additional context in comments.

Comments

1

you would use arguments.callee to get the calling function

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.