问题描述
我想通过获取执行上下文或更具体的 JS 函数的作用域链来了解 JS 函数的调用关系.考虑这个例子:
I want to know the JS functions' calling relationship by getting the execution context or more specifically scope chain of a JS function. Consider this example:
function one() {
var a = 1;
two();
function two() {
var b = 2;
three();
function three() {
var c = 3;
alert(a + b + c);
}
}
}
one();
我想知道一个 JS 函数中的每个局部变量和函数声明.我想 JS 函数的作用域链也许可以给我我想要的信息.但是不知道从哪里可以得到V8引擎里面函数的作用域链,有没有人能帮帮我?非常感谢!
I want to know every local variable and function declarations inside one JS function. I think the scope chain of the JS function maybe can give me the information I want. But I don't know where can I get the function's scope chain inside the V8 engine.Can any one help me with it?Thank you very much!
推荐答案
无论何时您想查看当时的调用顺序,您都可以简单地调用:console.trace();
where ever you want to see the call sequence at that point, you can simply call:console.trace();
这篇关于如何在 V8 引擎中获取 JavaScript 函数的执行上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!