Debugging javascript in IE is often like walking on a minefield with a blindfold on. You have no idea where you are when bombs go off. Thankfully, Microsoft provides a debugging tool called Microsoft Script Debugger which makes debugging javascript much easier. You can download the tool from here.

Once installed you get a full IDE in which you can debug your javascript. Hooray! There is also a IE Blog here which provides some interesting insights into debugging in Internet Explorer.