Monday, June 04, 2007

Debugging javascript with debugger

Aside from console.log, there is another javascript command that is available that has been immensely helpful in diagnosing javascript code

It's called "debugger".

Just place that command anywhere in your javascript code. When your page loads, execution will stop on the line where you placed debugger. This works on ...
  • Firefox with firebug installed
  • Internet Explorer with the Script Debugger installed

var myvar="this is myvar";
// execution stops here and the debugger window appears
debugger;
alert(myvar);