views:

108

answers:

4

This is my usual way to debug javascript. Include alert(0); to break the flow and find out what is happening.

sometimes when i need multiple check points i do

alert('the flow is now in function 1');
alert('the flow is now in function 2');

or sometimes just

alert('success');

i would like to know if there is any standard way for debugging adopted as i am finding my current method very intrusive.

thanks in advance..:)

+1  A: 

Firebug in Firefox is the best, but IE8 also has a pretty good javascript debugger. You can set breakpoints and step through your code to follow the program flow and view variable information, etc...

jaywon
can you suggest a debugger for IE where i can set break points..?
ZX12R
Andreas Niedermair
IE8 has a built in javascript debugger. Go To Tools->Developer Tools and you can access the debugger through that utility.
jaywon
+4  A: 

you might want to use the console... eg within firebug

otherwise you can use debugger; to break the script and force some debugger, or set breakpoints inside firebug (demo)

Andreas Niedermair
how do i set break points in firebug?
ZX12R
http://getfirebug.com/doc/breakpoints/demo.html
Andreas Niedermair
can i also know if there is a way to monitor variable values in firebug.?
ZX12R
just hover the variables while debugging and you get their value... but you can also set watches
Andreas Niedermair
Yes, download it and get to know it well. It will become your best friend :)
jaywon
thank you so much..
ZX12R
you're welcome!
Andreas Niedermair
A: 

If you prefer logging to using a debugger and need something that works in all browsers, I'd recommend my log4javascript.

Tim Down
interesting..will look into it..
ZX12R
A: 
Terrance