views:

92

answers:

6

What techniques (other than alert(message);) do you use to debug JavaScript/jQuery? Give particular attention to browser specific techniques.

Tools

FireFox

Chrome

Safari

Opera

Internet Explorer (I had to put it last)

+3  A: 

console is your friend, available by default in newer browsers, and you can add a whole lot of debugging to IE with FireBug Lite.

For other browsers:

For demonstration/test cases, jsFiddle is also an excellent tool.

Nick Craver
Nick, can we make this a wiki? I can't figure out how. I want to get some responses and summarize everything in the question.
Brad
@Brad - Users can't make questions a wiki, you have to flag it for a moderator to do so :)
Nick Craver
+1  A: 

I love Blackbird. It's a cross-browser JS logging framework, with support for debug/info/warning/error.

You can display the console at any time with the F2 func key.

http://www.gscottolson.com/blackbirdjs/

Oli
+1  A: 

If you are looking for an alternative for alert(message);, it is console.log(message);

The requirement is that you need any modern browser or a browser with developer tools installed.

Nirmal
+2  A: 

If you're concerned about using console.log because not all browsers support this, it's easy to workaround with a couple lines of javascript:

console = console || {};
console.log = console.log || function(){}; //you can change this to do whatever you want, or leave it to just keep js errors from being thrown
soslo
+1  A: 

The Chrome Developer Tools are a direct descendant of the Safari (WebKit) Developer Tools.

jsumners
+1  A: 

More in testing than debugging domain.

Selenium - for GUI tests

JSUnit - for unit testing

Mchl