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 difficulty in finding these mistakes, or bugs, also increases. In this chapter we will look at various techniques that will help us minimize the problems that arise from this situation.
We'll start by taking a look at the top seven JavaScript coding mistakes. Once we know what they are, we'll be able to look out for them when writing code. Hopefully, so that we won't make them so often!
Then we'll look at the Microsoft script debugger, which can be used with Internet Explorer. We'll see how we can use it to step through our code and check the contents of variables while the code is running, a process that enables us to hunt for difficult bugs. We'll also take a briefer look at the debugging tools available for Netscape 7.
Finally, we'll look at how we can cope with errors when they do happen, so that we prevent users from seeing our coding mistakes.