JavaScript basics 1: JavaScript errors, javascript Basics
Try statement test code block error.
Catch statement processing error.
Custom error in throw statement creation.
Errors will occur. When the JavaScript engine executes JavaScript code, various errors may occur: syntactic errors, usually code errors or typos caused by programmers. It may be a spelling error or a lack of functionality in the language (possibly due to browser differences), or an error may be caused by incorrect output from the server or user. Of course, it may also be caused by many other unpredictable factors. When an error occurs, when something goes wrong, the JavaScript engine usually stops and generates an error message. The technical term used to describe this situation is: JavaScript will throw an error. The try statement allows us to define the code block for Testing errors during execution. The catch statement allows us to define the code block to be executed when an error occurs in the try code block. The try and catch statements in JavaScript are paired.
The following is an example:
<! DOCTYPE html>
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.