function main()
{
Hello();
}
function Hello()
{
// How do you find out the caller function is \'main\'?
}
Is there a way to find out the call
I usually use (new Error()).stack
in Chrome.
The nice thing is that this also gives you the line numbers where the caller called the function. The downside is that it limits the length of the stack to 10, which is why I came to this page in the first place.
(I'm using this to collect callstacks in a low-level constructor during execution, to view and debug later, so setting a breakpoint isn't of use since it will be hit thousands of times)