javascript调试:有没有办法打破变数值的变化? [英] javascript debugging: Is there a way to break on a change of variable value?

查看:108
本文介绍了javascript调试:有没有办法打破变数值的变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与其他问题类似,像这样一个

有没有办法打破任何javascript调试器中变量值的变化? (像IE Developer工具,Visual Studio或Firebug?)

Is there a way to break on the change of a variable value in any javascript debugger? (like IE Developer tools, Visual Studio, or Firebug?)

我想这是一个像watch variable这样的东西,但是我希望能够看到callstack实际发生变化时暂停它。

I guess it's something like a "watch variable", but I want to be able to see the callstack and pause it when the change to the variable actually occurs.

另一种方法可能是用自定义设置器覆盖值设置,并在其中放置一个断点,但不幸的是这不适用于IE afaik。

An alternative approach might be to override the value setting with a custom setter, and put a breakpoint in that, but unfortunately that won't work for IE afaik.

更新
似乎这种行为至少可用于非托管代码写入C ++ 所以我认为也许一个用C ++编写的JavaScript引擎(Google的V8)可能有类似的东西,但似乎也没有我想要的东西。

UPDATE It appears that this type of behavior is available at least for unmanaged code written in C++ So I thought maybe a javascript engine written in C++ (Google's V8) might have something similar, but that doesn't appear to have what I want either.

推荐答案

您甚至不需要IDE - 您可以使用Object.watch():

You don't even need an IDE - you can use "Object.watch()":

Object.Watch教程

如果您使用任何一个调试器我强烈推荐Firebug。对于您所有的Javascript,HTML和CSS需要: - ):

If you use any one debugger, I'd strongly recommend Firebug. For all your Javascript, HTML and CSS needs :-):

http ://getfirebug.com/javascript

这篇关于javascript调试:有没有办法打破变数值的变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆