4.JS exception handling and event handling

Source: Internet
Author: User

Abnormal:

1. Exception: When the JS engine executes the JS code, an error occurs, causing the program to stop running.

2. Exception thrown: When an exception is generated and an error message is generated for this exception.

3. Exception Capture:

try{

The code block in which the exception occurred;

}catch (Err) {

Error handling information;

}

4.Throw statement:

Create a custom error by using the throw statement;

Usually throw is used in conjunction with try{}catch{}.

Write an example:

Function Demo () {

try{

var e=10;

if (e==10) {

Throw "Not equal to 10 ah";

}catch (Err) {

alert (err);//The output here is not equal to 10.

}

Event:

Event:

4.JS exception handling and event handling

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.