JQuery (10)

Source: Internet
Author: User

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)

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.