Thursday, December 14, 2006

“debugger”, the magic JavaScript statement

This post is dedicated to all the Javascript programmers who still use alerts to debug their code.

Not sure about you, but I have always struggled to set and enable Visual Studio breakpoints to debug my Javascript code until I have found about a magic statement named debugger.

To use it:
  1. Make sure “Disable Script Debugging” is unchecked in Internet Explorer, Tools (menu) -> Internet Options… (submenu) -> Advanced (tab) -> Browsing (node).
  2. Put the debugger; statement anywhere in your code where you want the breakpoint.
  3. Execute your web application and when the browser script engine interprets the statement, it launches the debugger and breaks on the statement line.

No comments: