user420667 user420667 - 9 days ago 6
Javascript Question

javascript debugging: Is there a way to break on a change of variable value?

Similar to other questions here, like this one.

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.

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.

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.

Answer

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

Object.Watch Tutorial

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

http://getfirebug.com/javascript