JavaScript Debugging Tips

Source: Internet
Author: User

1. Print out information

Console.log for common printing information
Console.table Print object information;
Console.trace (' trace car ') looks at the function's call stack, particularly effective.

3. Breakpoint Debugging

There are three ways to
First, directly find the code line add a breakpoint;
Second, add debugger in the code, the browser will automatically stop in the debugger
Enter Debug (car.funcy) on the console.

if{    debugger;}
4. Responsive commissioning

You can debug a mobile-side viewshed

5. Count the time required for code block execution

Particularly effective for statistical optimization of loops

console.time(‘Timer1‘);var= [];for(var=0;<100000; i++){   items.push({index: i});}console.timeEnd(‘Timer1‘);
7. {}Beautify the compressed code 8. Parameters accepted by the monitoring function

In console inputmonitor(functionName)

9. Quick access to elements

Enter $ (' Css-selector ') in the console to return the first matching element;
$$ (' Css-selector ') will return all matching elements.

10. You can edit the network request by right-clicking on the Network tab.

This action is used to fill in missing field re-request parameters, perfect parameters are particularly effective

11. Right-click on the DOM panel to add monitoring to see why DOM elements change

JavaScript Debugging Tips

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.