Debugging JavaScript using Visual Studio

I really like inbuilt JavaScript debugger of Visual Studio which works like charm with IE browser, which is rarely used by most web developers now days. To debug Javascript code, developers usually opt to put alert or console log in the code to test or evaluate value of any Javascript object. But debugging Javascript through IDE is much more quicker comparatively. For debugging JavaScript, all you need is to enable script debugging in IE and place some junk characters in your JavaScript code where you want to debug and that' all. Using VS you can step into, step over, place break point in your JavaScript code, adding watch for any object, or even evaluate any JavaScript object using QuickWatch.

To start debugging, as I mentioned earlier, you need to enable script debugging in IE.
Navigate to following in IE: Tools > Internet Options > Advanced Tab

In the settings TreeView, check off the node "Disable Script Debugging (Internet Explorer)".

Now in your Javascript code and place a string with some junk characters (something like "sdsdasd") where your want to start debugging process. I always prefer to use "_test" as standard practice for me, to put junk string as it help me to find all junk string in the code when I am done with debugging process.

After placing junk string in your code, start your web application and navigate till you reach at that junk string in JavaScript code. IE will then automatically shift you to the VS with an error message "Microsoft JScript runtime error: '_test' is undefined". Click on "Break" button and now your are in debug mode. Move the cursor to the next line of that junk string and set it as next statement (right click anywhere on that line & click "Set Next Statement": Ctrl+F9). Now you can debug your JavaScript code as you usually do in C#/VB.NET code.

Update: You can also place debugger; keyword as script break point instead of that junk string to start debugging process.