Posts Javascript Debugging in Visual Studio

Javascript Debugging in Visual Studio

Many a times people get stuck in solving the Javascript issues just because they are not able to debug the code. Debugging is one of the things which you should be very good at and it also checks your patience.

The latest version of Visual Studio i.e. VS 2008 has inbuilt feature that helps you to debug the javascript code just like any other code behind or server side code. All you need to do is set the breakpoint on the javascript code and the breakpoint will be hit when the code execution reaches that point.

But this is not possible in VS 2005 so the question arises how to debug Javascript in VS 2005?

The answer is simple all you need to do is write “debugger” above the line you want the breakpoint to hit. So that means write the word “debugger” without double quotes before the breakpoint line in javascript and when that code will be executed an window will popup asking you to choose which debugger you want to use to debug the javascript code and you can select the appropriate debugger to debug the javascript code. And if you have firebug in Firefox than you can debug your javascript in Firebug also it allows you to set the breakpoint in the code the same way as you do in the server side code in and you can step-in, step-out same way.

for e.g.

function validate()


var a=10;var b =20;


var c=a+b;


In this the breakpoint will hit at “var c=a+b”.

This post is licensed under CC BY 4.0 by the author.