开发者

is there an easy way to track a javascript variable with firefox?

I am looking开发者_Go百科 for an easy way to track the many changed of a variable in firefox.

I am looking for something that will not require me to add reduntant code, like alert, or console.log, but rather way to tell firefox to report each time a JS var is changed

am I dreaming?


firebug allows you to watch variables.

http://getfirebug.com/wiki/index.php/Script_Panel


You can add it to the "Watch" tab under the "Script" tab in Firebug. This will always show you the current value of a watched item, even if it's out of scope and null. Mix that in with break points and you can get what you want I think.

Additionally, console.log isn't redundant. You could set a global variable that would turn on the logs, something like:

if (debugging) {
    console.log("var test is set at " + test);
}

That way they'd act more like trace points that you could trigger. For a bigger app this overhead pays for itself quite quickly.


It sounds like you are looking for Firebug. Check it out.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜