Java Reference
In-Depth Information
4
Common Mistakes,
Debugging, and Error
Handling
Even a JavaScript guru makes mistakes, even if they are just annoying typos. In particular, when
code expands to hundreds of lines, the chance of something going wrong becomes much greater.
In proportion, the diffi culty in fi nding these mistakes, or bugs, also increases. In this chapter you
will look at various techniques that will help you minimize the problems that arise from this
situation.
You'll start by taking a look at the top seven JavaScript coding mistakes. After you know what
they are, you'll be able to look out for them when writing code, hopefully, so that you won't make
them so often!
Then you'll look at how you can cope with errors when they do happen, so that you prevent users
from seeing your coding mistakes.
Finally, you'll look at the debugging tools in Microsoft's Internet Explorer (IE8), Firebug (an add-on
for Firefox), Safari's and Chrome's Web Inspector, and Opera's Dragonfl y. You'll see how you can use
these tools to step through your code and check the contents of variables while the code is running,
a process that enables us to hunt for diffi cult bugs. You'll also take a briefer look at the debugging
tools available for Firefox.
D'oh! I Can't Believe I Just Did T hat:
Some Common Mistakes
There are seven common mistakes made by programmers. Some of these you'll learn to avoid as
you become more experienced, but others may haunt you forever!
Search WWH ::




Custom Search