Only one tip that I didn't know before: When you want to debug Javascript code you can start your debugger (Visual Studio .NET or Script Debugger), search for the correct iexplore.exe process, attach it and go on debugging.
A very fast way is to write "javascript:debugger;" in the address line, select your debugger and start debugging. Also, the "debugger;" command can be used in Javascript code:
if(typeof(res)=="object") debugger;
This line will start the debugger if the type of res is object.