1. users using the Mozilla Browser can view the errors found by the browser directly on the Javascript console under tools.
Ii. Use exception handling to catch JavaScript exceptions.
The following is an example of JavaScript exception handling.
VaR array = NULL;
Try {
Document. Write (array [0]);
} Catch (ERR ){
Document. writeln ("error name:" + err. Name + "");
Document. writeln ("error message:" + err. Message );
}
Finally {
Alert ("object is null ");
}
ProgramExecution Process
1. When array [0] is created, array is an empty object because array [0] is not created. If array [0] is called in the program, the object is null.
2. The catch (ERR) statement captures this exception and prints the Error Type through err. Name, and err. Message prints the error details.
3. Finally is similar to Java finally, and will be executed no matter whether exceptions exist.
We will summarize the information corresponding to the six values of error. Name:
1. evalerror: eval () is used and defined differently.
2. rangeerror: value out of bounds
3. referenceerror: Invalid or unrecognized reference value
4. syntaxerror: Syntax Parsing Error
5. typeerror: Incorrect operand type
6. urierror: The URI processing function is improperly used.