获取对 javascript 中函数的所有调用
有没有办法找到所有调用另一个函数的函数? (然后通过扩展,调用这些函数的所有函数等)
我的猜测是,这不可能适用于所有情况,但肯定可以适用于大多数用例,不是吗?就像如果有人将其函数定义为:
new Function('a','b', 'return a'+'+b;');
找到内部引用可能会更棘手。
提前致谢。
Is there a way to find all the functions that call another function? (And then 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有一个arguments.caller,但它已被弃用。 Function.caller 是替代品,但您需要函数名称 - 我会使用 arguments.callee 或直接使用名称。
https://developer.mozilla.org/en/JavaScript/Reference/Functions_and_function_scope /参数/调用者
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
除了其优秀的大纲视图之外,Eclipse 还允许您通过选择函数的声明然后按 F2 来“集中”源代码中函数的调用。外观将显示在右侧栏中。
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.