function main() { Hello(); } function Hello() { // How do you find out the caller function is \'main\'? }
Is there a way to find out the call
You can get the full stacktrace:
arguments.callee.caller arguments.callee.caller.caller arguments.callee.caller.caller.caller
Until caller is null.
null
Note: it cause an infinite loop on recursive functions.