JavaScript Basics 1:javascript Errors-Throw, Try, and Catch__java

Source: Internet
Author: User

The TRY statement tests the code block for errors.
The catch statement handles the error.
Throw statement to create a custom error.

Errors are certain to occur, and when JavaScript engines execute JavaScript code, various errors occur: It may be a syntax error, usually a programmer-caused coding error or a typo. It may be a spelling error 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 for describing this situation is that JavaScript will throw an error. The Try statement allows us to define blocks of code that are incorrectly tested at execution time. The catch statement allows us to define the block of code that is executed when an error occurs in a try block of code. JavaScript statements try and catch appear in pairs.


The following is an example explanation:


<! DOCTYPE html>  




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.