Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
46
rated 0 times [  52] [ 6]  / answers: 1 / hits: 36476  / 13 Years ago, thu, october 27, 2011, 12:00:00

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.


More From » debugging

 Answers
39

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



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



Update for 2019:




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


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


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


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


  • Chrome debugger is well integrated with the MSVC IDE.


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



[#89433] Monday, October 24, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nadiaa

Total Points: 572
Total Questions: 113
Total Answers: 113

Location: Mauritania
Member since Sun, Oct 17, 2021
3 Years ago
;