JavaScript base 1:javascript Errors-Throw, Try, and Catch

Source: Internet
Author: User

The TRY statement tests the code block for errors.
The catch statement handles the error.
The throw statement creates a custom error.

Errors are bound to occur, and when the JavaScript engine executes JavaScript code, various errors occur: it can be a syntax error, usually a coding error or typos caused by a programmer. It may be a misspelling or a missing feature in the language (possibly due to browser differences), possibly due to error output from the server or user. Of course, it may also be due to many other unpredictable factors. When an error occurs, the JavaScript engine usually stops and generates an error message when something goes wrong. The technical term that describes this situation is that JavaScript throws an error. The Try statement allows us to define a block of code that performs error testing at execution time. The catch statement allows us to define a block of code that executes when a try block of code has an error. The JavaScript statement try and catch are paired occurrences.


Here is an example of the explanation:


<! DOCTYPE html>



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

JavaScript base 1:javascript Errors-Throw, Try, and Catch

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.