Chapter 9

Debugging Your Code

IN THIS CHAPTER

check Learning JavaScript’s error types

check Debugging errors using the Console

check Setting breakpoints

check Watching variable and expression values

check Learning JavaScript’s most common errors and error messages

Sometimes it pays to stay in bed on Monday, rather than spending the rest of the week debugging Monday’s code.

— CHRISTOPHER THOMPSON

It usually doesn’t take too long to get short scripts and functions up and running. However, as your code grows larger and more complex, errors inevitably creep in. In fact, it has been proven mathematically that any code beyond a minimum level of complexity will contain at least one error, and probably quite a bit more than that.

Many of the bugs that creep into your code will be simple syntax problems you can fix easily, but others will be more subtle and harder to find. For the latter — whether the errors are incorrect values being returned by functions or problems with the overall logic of a script — you’ll need ...

Get Web Coding & Development All-in-One For Dummies 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.