中断变量值的变化 [英] Break on a change of variable value

查看:34
本文介绍了中断变量值的变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与此处的其他问题类似,就像这个.

Similar to other questions here, like this one.

有没有办法在任何 JavaScript 调试器中中断变量值的更改?(例如 IE 开发者工具、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)?

我想它类似于观察变量",但我希望能够看到调用堆栈并在实际发生变量更改时暂停它.

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 引擎(谷歌的 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

==========================================================

===========================================================

2019 年更新:

  • Object.Watch 是古代历史.巧合的是,它在大多数现代浏览器中都不可用.

  • Object.Watch is Ancient History. Uncoincidentally, it's unavailable in most contemporary browsers.

我个人最近最喜欢的 JS 调试工具是 Chrome 开发者工具.

My personal favorite JS debugging tool these days is Chrome Developer Tools.

我个人最喜欢的 JS IDE(用于 Angular、.Net Core 等)是 Microsoft Visual Studio Code (MSVC).

My personal favorite JS IDE (for Angular, .Net Core, etc) is Microsoft Visual Studio Code (MSVC).

您可以使用 Chrome 调试器(就像使用 FF Firebug 一样)执行任何预期的"调试操作(包括设置监视).

You can do just about any "expected" debugging operation - including set watches - with the Chrome debugger (just as you could with FF Firebug).

Chrome 调试器与 MSVC IDE 集成良好.

Chrome debugger is well integrated with the MSVC IDE.

两者都是免费的"(至少像啤酒一样免费");两者都在 Windows、Mac 和 Linux 上运行良好.

Both are "free" (at least "free as in beer"); both run well on Windows, Mac and Linux.

这篇关于中断变量值的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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