开发者

get all calls to a function in javascript

开发者 https://www.devze.com 2023-04-10 05:40 出处:网络
Is there a way to find all the functions that call another function?(And then开发者_如何学JAVA by extension, all the functions that call those functions, etc.)

Is there a way to find all the functions that call another function? (And then开发者_如何学JAVA by extension, all the functions that call those functions, etc.)

My guess is it won't be possible for all cases, but certainly it could be done for most use cases, no? Like if somebody defines their function as:

new Function('a','b', 'return a'+'+b;');

it might be more tricky to find inner references.

Thanks in advance.


There is a arguments.caller but it's deprecated. Function.caller is replacement but you need function name - I'd use arguments.callee or directly the name.

https://developer.mozilla.org/en/JavaScript/Reference/Functions_and_function_scope/arguments/caller


In addition to its excellent outline view, Eclipse lets you "focus" the calls of a function in the source by selecting its declaration and then pressing F2. Appearances will be displayed in the right bar.

0

精彩评论

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