Algorithmic and Process Control-high performance JavaScript

Source: Internet
Author: User

Summarize:

1.for, while, Do-while loop performance is comparable, and no one loop type is significantly faster than or full of other types.

2. Avoid using the for-in loop unless you want to traverse an object with an unknown number of attributes.

3. The best way to improve cycle performance is to reduce the number of operations per iteration and reduce the frequency of iteration iterations.

4. Switch is always faster than if-else, but always the best way

5. When judging more conditions, use the query table faster than If-else and switch

6. The browser's call stack limits the use of recursive algorithms in JavaScript, and stack overflows can cause other code outages

7. If you encounter a stack overflow error, you can change to an iterative algorithm.

Algorithmic and Process Control-high performance JavaScript

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.