Chapter 38. Debugging with Firebug

Before JavaScript became the world's most popular programming language, it was actually looked down upon as being a quirky language that wasn't worth any real developer's time. This outlook on JavaScript was primarily caused by two issues:

  • Developers didn't fully understand the language.

  • There were no decent development tools available.

The popularity of web applications and Ajax essentially pushed JavaScript into the limelight. As a result, developers finally began to understand the language, and some of them started building development tools for JavaScript.

Today, there are a variety of tools available to developers. Probably the most important are the JavaScript debuggers present in all major browsers. With a debugger, you can pause the code execution of your script, and with a process known as stepping, you can execute the lines one at a time to find bugs in your code.

Debugging is universally necessary across all browsers and languages. Although some debugging tools offer features that other tools may not have, all debugging tools are based upon the following concepts:

  • Breakpoints: tell the debugger where it should break or halt code execution. You can set a breakpoint on any line in your code; the debugger will pause there.

  • Stepping: lets you execute one statement of code at a time. There are three ways to step through code:

    1. Step Into: executes the next line of code. In the case of a function, the debugger executes the function and breaks at the ...

Get JavaScript® 24-Hour Trainer now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.