【问题标题】:How to get local variables array with firefox/firebug/chrome debugger?如何使用 firefox/firebug/chrome 调试器获取局部变量数组?
【发布时间】:2015-07-09 19:48:52
【问题描述】:

firefox/firebug/chrome 调试器是否提供 api 用于在控制台中获取局部变量数组?或者有什么软件提供这样的api?

【问题讨论】:

  • 嗯,devtools/firebug 使用的调试协议确实提供了这个 API,是的。但是你到底需要这个做什么?您不想编写自己的调试器,是吗?
  • 您可以在调试器中简单地检查 范围,但不能以编程方式。

标签: javascript javascript-debugger


【解决方案1】:

局部变量,如函数范围内的变量?

不,除非您使用 thisprototype 从函数中公开它们,否则您将无法查看它们

编辑:更多信息

function Car(color){ this.color = color; }
var myCar = new Car("red");
myCar.color // This would output red, and if myCar was globally defined you could view it.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多