开发者

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

开发者 https://www.devze.com 2023-01-21 09:19 出处:网络
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, bu

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

精彩评论

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