One: The wrong Error object in javascript:
Java-like error base class Exception,javascript a base class Error,error object has the following characteristics:
pname– A string that represents the type of error pmessage– the actual error message
The name of the Error object corresponds to its class, which can be one of the following values
1. Evalerror: Error occurred in eval () function
2, Rangeerror: The value of the number exceeds the range that JavaScript can represent
3, Referenceerror: Use of illegal references
4. SyntaxError: A syntax error occurred in the eval () function call.
5. TypeError: The type of the variable is not what you expect
6. Urierror: An error occurred in the encodeURI () or decodeURI () function
Note: Mozzilla and IE both extend the Error object, such as IE provides a number attribute to indicate the wrong code, or description instead of a message
Introduce a throw statement for a purposeful throw exception
The syntax is as follows: Throw Error_object
Error_object can be a string, a number, a Boolean value, or an actual object. Such as:
Throw "An error occurred";
Throw 5007;
throw true;
throw new Object ();
throw new Error ();
throw new error ("Error");
throw new Error (10001, "error");
Other error subclasses can also use the
Such as:
throw new Sytaxerror ("syntax error");
throw new TypeError ("wrong data type");
throw new Evalerror ("eval type error");
A simple instance of a custom exception:
JQuery (10)