O'Reilly logo

Beginning JavaScript, 5th Edition by Jeremy McPeak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

18Common Mistakes, Debugging, and Error Handling

WHAT YOU WILL LEARN IN THIS CHAPTER:                

  • Spotting common mistakes that everyone makes—even pros!
  • Handling runtime errors, or exceptions, with the try…catch statement
  • Debugging JavaScript with the development tools of various browsers

WROX.COM CODE DOWNLOADS FOR THIS CHAPTER

You can find the wrox.com code downloads for this chapter at http://www.wiley.com/go/BeginningJavaScript5E on the Download Code tab. You can also view all of the examples and related files at http://beginningjs.com.

Even a JavaScript guru makes mistakes, even if they are just annoying typos. In particular, when code expands to hundreds or thousands 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 you look at various techniques that will help you minimize the problems that arise from this situation.

You 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 look at how you can cope with errors when they do happen, so that you prevent users from seeing your coding mistakes.

Finally, you look at the debugging tools in Microsoft’s Internet Explorer (IE11), Firebug (an add-on for Firefox), Chrome’s Web Inspector, and Opera’s Dragonfly. You see how you can use these tools to step ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required