Simple Javascript Debugger

While developing javascript, to debug any line of code, I always put Alert(value);. Most of us ever did this don’t we? Alert things is the fastest way to check value within running code. But, recently, I found interesting article on Firebug’s blog about “Firebug Logging”.

They said : Having a fancy JavaScript debugger is great, but sometimes the fastest way to find bugs is just to dump as much information to the console as you can. Firebug gives you a set of powerful logging functions that you can call from your own web pages. Using console makes our code clean, no pop-up message, and I can try to debug within Live site and won’t interrupt user. Debug’s result will be written inside console, for those who ever play with browser’s developer tools. Just press F12 inside browser’s window, each browser has it’s own tools.

How to? It’s very simple code, take a look!

Console usage on Chrome
Console on Chrome
Console usage on Firefox (with firebug)
Console on Firefox
Console usage on IE
Console on IE

On browser IE, you can see, it throws errors, because IE does not support property of debug. For best practice, we could code like below:

     console.debug(text + "DEBUG");   

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s