Solutions that can be used to debug JavaScript errors _ javascript skills

Source: Internet
Author: User
Some js Errors often occur during js writing. The following article describes the relevant debugging methods as the key to solving the errors. A uses the alert () and document. write () methods to monitor variable values.
If you want to interrupt code execution and monitor variable values, use the alert () method;
If you want to view a large number of values, use the document. write () method to avoid repeated clicking the "OK" button;

B. Use the window. onerror event
When an exception occurs on the page, the onerror event is triggered on the window object. It can tell developers related error information to a certain extent.
Example:

The Code is as follows:


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.