How to identify the caller of function in Javascript?
I have a function, say f(args)
, that is being called from many places in my code.
When args
is undefined f()
throws an exception.
I would like to id开发者_运维百科entify who called f()
with the undefined
parameter.
What would be the easiest way to find the exact line (file name + line number) that called f()
?
Is that possible to see the caller in Firebug ?
yes.
When you breakpoint it.
In stack
. between watch
and breakpoints
If you need this information without any tool, with a piece of code:
Check out this question
Also,
HERE's an example of writing a backtrace. You could use this for getting the whole trace. (for example if you need the caller of the caller)
If you set a breakpoint in IE developer toolbar, when the breakpoint is hit, you can see the call stack from th script tab, then select the call stack tab on the right. you can click on each stage of the call stack to navigate and inspect all the callers, etc.
精彩评论