Examples of common exception errors are as follows:
Name Error name
Number error
Description description
Message error messages
Common exceptions
Evalerror
Rangeerror
Referenceerror
SyntaxError
TypeError
Urierror
Code:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<TITLE> exception Handling in JavaScript-www.cxybl.com</title>
<meta name= "Content-type" content= "Utf-8" >
<meta name= "Author" content= "" >
<meta name= "Keywords" content= "" >
<meta name= "Description" content= "" >
<script language= "JavaScript" >
<!--
Four properties common to exception objects
/*
try{
alert (result);
}catch (e) {
Alert ("Abnormal name:" +e.name);
Alert ("Exception number:" +e.number);
Alert ("Descriptive information of the exception:" +e.description);
Alert ("error message for exception:" +e.message);
}
*/
Throw an exception throw way
Requires the user to enter a number greater than or equal to 0 to less than or equal to 10, and if the value entered is less than 0, the prompt input cannot be less than 0; If you enter a value greater than 10, you are prompted to enter a number that is not a numeric type.
/*
try{
var result=prompt ("Ask the user to enter a number from 0 to 10");
if (result<0) {
throw new Error ("-1", "input value cannot be less than 0");
}else if (result>10) {
throw new Error ("-2", "the value entered cannot be greater than 10");