Find the function calling the function in JS?
What's the best way to find the function that's calling the function?
For example, if I have
function fir开发者_运维问答st(){
doSomething();
}
// Lots of code
function doSomething(){
alert('Somehow, I know that' + ________ + 'function called me...');
alert('Boink, hit an error, but now you know what function called me');
}
Is there any way to get that calling function? Thanks!
Replace ______ with doSomething.caller
.
精彩评论