19Error Handling and Debugging
JavaScript has traditionally been known as one of the most difficult programming languages to debug because of its dynamic nature and years without proper development tools. Errors typically resulted in confusing browser messages such as “object expected” that provided little or no contextual information. The third edition of ECMAScript aimed to improve this situation, introducing the try-catch
and throw
statements, along with various error types to help developers deal with errors when they occur. A few years later, JavaScript debuggers and debugging tools began appearing for web browsers. Modern web browsers feature robust suites of JavaScript debugging capabilities.
Armed with the proper language support and development tools, web developers are now empowered to implement proper error-handling processes and figure out the cause of problems.
BROWSER ERROR REPORTING
All modern web browsers have some way to report JavaScript errors to the user. By default, all browsers hide this information, both because it's of little use to anyone but the developer, and because it's the nature of web pages to throw errors during normal operation. ...
Get Professional JavaScript for Web Developers, 5th Edition 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.