JS error Handling

Source: Internet
Author: User

An exception state that causes the program to continue execution is called an error.

JS, an error type object is created automatically

There are 6 error types in JS:

SyntaxError syntax error

Referenceerror reference error, variable or object not found

TypeError type error, incorrect use of method in object

Rangeerror range error, parameter over range

Evalerror calling the Eval function is an error

Urlerror Urlu Error

How to handle errors: Trycatch blocks

1 Try {2     // error-prone code 3 }catch(err) {4     // error handling 5 }  Finally{6     // code that is always executed, typically used to free resources 7 }
  

Using Trycatch can result in longer code execution times, and it is recommended to use If...else to determine which errors have been predicted. Only unpredictable errors are used with the Try...catch statement (minimizing the containing code).

JS error 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.