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 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.