开发者

Find the function calling the function in JS?

开发者 https://www.devze.com 2023-01-07 21:07 出处:网络
What\'s the best way to find the function that\'s calling the function? For example, if I have function fir开发者_运维问答st(){

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消