Advanced Debugging with JavaScript…
Talking about Advanced JavaScript debugging.
First of all about tools. Currently, the most powerful debuggers are the Firebug extension in Firefox and the Opera Dragonfly debugger in Opera.
Firebug is well-known, userfriendly, and its more than enough in most situation. But from my own expierence, sometimes Dragonfly can help to debug code that has been “packed” and needs to be unpacked using eval(), when Firebug can’t. I was faced with such situation about half a year ago when I need to fix an application based on Dojo.
Now about techniques. Here is an particular interesting technique that I found from the article “Advanced debugging with JavaScript” :
…Debuggers for many other programming languages have a “watch” concept that can break into the debugger when a variable changes. Neither Dragonfly nor Firebug currently support “watch” but it’s easy to get the same effect by adding the following line of debugging code at the top of the source of the script you’re troubleshooting:
__defineSetter__('prop', function() { debugger; });
Using getters and setters can emulate “watch” functionality and help you set “smart” breakpoints.