- As developers, our main job is to find ways to turn ideas into working products. Apps, websites, art pieces, whatever. Knowing how to write code is a beautiful thing, with the computer doing exactly what we tell it to do, or so we hope. But trouble can arise when the things we've written don't produce the results we're looking for. As cool a job description as we have, the actual work is often trying to track down and trying to fix problems in the code we've written, or heaven forbid that someone else wrote.
Of course, you don't always have to use a debugger. If you've ever written any code, you've no doubt popped up alerts or logged console messages to help figure out what's happening in your code at a certain point. And I'm certainly not going to tell you to stop doing that. For some kinds of problems, that's totally sufficient. But with a debugger, you can do that basic stuff and other, more advanced inspections. You can pause the execution of your code and step through it line by line, function by function. And while it's stopped, you can look at every variable currently known to see what it contains.
You can track particular variables over time, watching their values change or not change as you step through your code. You can even step back in time, to see how variables changed at every step on the way to where you are. The first time you use a debugger, it can almost feel like magic. Overall, you end up spending much less time guessing, so you can spend more time thinking, and solving problems faster. And that's really what we're here for, right?
- Getting the browsers and plugins
- Leveraging the Console API
- Using breakpoints
- Using step functions
- Watching variables
- Debugging jQuery, WordPress, mobile sites, and more