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