4

How to Debug javaScript Error Using Firebug?

0

6 Answers 6

23

Debug using FireBug.

Just check the line on which the error is occuring, then, just before that line, write a "debugger" call.

debugger; //Will invoke FireBug's debugger.
var err = abcs; //Line containing error
Sign up to request clarification or add additional context in comments.

3 Comments

Great link. firebug rocks. +1
Actually, the "debugger" keyword will just invoke an exception which is then caught by firebug. There's nothing firebug specific about it, Internet Explorer can also catch it and ask you to choose a debugging engine for it.
Excellent , have been using firebug for a long time, but did not know the usage of debugger key word for fire bug. I was using break points in js for that purpose. Up voted .
2

To debug an error in firebug :

  • 1- select inspect tab from menu
  • 2- Set break point in the line that causes error
  • 3- Refrsh the page
  • 4- use F10 to step by step debug and F5 to end debgging

It's like debgging of visual studio

Comments

1

Use the console.log(yourObject) function to output anything to the firebug console. It is just like running a var_dump and you can view all your objects and their contents. This is very helpful if you want to check on the contents of a particular variable or even a particular DOM object.

Instead of using cheap alerts - the console.log() function is cleaner and you can see all the outputs neatly in your console pane.

Note however you need to remove all references to the console.log function when you deploy your website as it would not run in IE.

Comments

0

you can put breakpoints in the code, and wait for the execution to hit them. Then you can walk in the code, and use watches to know the values of variables.

1 Comment

LOL - uh, all you did was describe the debugging process for just about any language in the world, I don't see how this even begins to answer the question. -1
-1

Why Firebug , try Visual studio , it has a rich debugging features ;)

4 Comments

Firebug also has rich debugging features, lets you debug under Firefox, is much smaller and less memory hungry than Visual Studio, and runs on platforms that are not Microsoft Windows.
How do you debug javascript in FireFox in Visual Studio?
in the question its not mentioned that he wants to debug in firefox and at first before edit it was just about how to debug javascript !
Visual Studio is a good tool, especially for debugging JavaScript running in IE; if you are using Firefox though, Firebug is probably the better option.
-1

You can use Firebug, and for debugging in chrome, you can use firebug lite

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.