12. Error Management

One of the most profound differences between the beginning programmer and the expert is error management. Certainly errors will occur regardless of the skill level of the programmer, as the user causes many problems. But the more seasoned developer does a markedly better job of handling errors when they do occur. In this chapter, you’ll learn three ways to prevent and deal with errors. The first is called exception handling, and takes advantage of JavaScript’s built-in syntax: try...catch. The second approach is the use of assertions, which is an easy debugging tool utilized while writing code. Building on that concept, the chapter concludes with an introduction to unit testing.

Catching and Throwing Errors

Most of the examples ...

Get Modern JavaScript: Develop and Design now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.