JavaScript several easy to error point record _ basic knowledge

Source: Internet
Author: User

1. Empty the input label is worth the time, can not use HTML ("") empty, to use Val ("") empty

2. If the event is bound multiple times, the callback function is executed several times after the event is triggered, all the best to write the function of the binding event individually, or when the binding must be repeated, each time it is untied

3.jquery Selector If you are returning an array of jquery objects, you can use each to do so, or if you are working directly on the array, you may be manipulating only the first object of the group, not the traversal

4. Case sensitive, for example if it is written as if. ToString () was written in ToString (), touppercase written in toUpperCase

5.document.getelementbyid (""), the arguments in parentheses remember to quote

6.setTimeout ("function", delay time); function quotes

7. The traversal of an array is best done through a for loop, not through for. In is much less efficient than for. At the same time there is a certain performance overhead when calling the array length property, so it is best to assign the length property of the array to a variable to improve performance.

8. With regard to functions, this is the most important object in JavaScript, and we can pass it as a parameter. The simplest thing here is settimeout, the parameter of this function call is actually a function.

9. Order of execution of procedures:
Program execution, from top to bottom, if you encounter alert, the browser stops there and does not continue until you click OK. If the script statement is inside the head, alert is the whole thing, it will be displayed first and then the contents of the body are loaded. And if alert is inside the function, alert will work only if you call the function.

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.