1, declare the variable to be assigned the initial value
2, try to avoid declaring global variables, you can reduce the duplicate name of the system
3, when writing a large number of JS code, you will inevitably encounter a naming conflict, which can be simulated by the namespace mode
To avoid conflict.
4, try to avoid the use of global variables, search global variables will be a layer of search for each scope range,
Time-consuming and inefficient.
5, use the impairment cycle or optimize the cycle condition, do not write i<xxx in the cyclic condition. Length, but with a
Variable to replace, I<len. Because each loop performs a calculation Length,var i=0 also gets out.
To.
6, Avoid using eval ("alert ();") SetInterval ("MyFunc ();", 1000) This
Re-parse the code, inefficient!
7, using native methods, such as the built-in join () reverse () use these browsers originally
There are methods, do not write with their own myjoin, such as low performance, native methods are used C or C
+ + Write, high performance
8, use switch as much as possible instead of multiple if else
9. Try to reduce the number of statements.
var fragment=document.createdocumentfragment (); Using document fragmentation,
Avoid updating pages multiple times
120 days of 1200 hours of wisdom in the junior students. NET (vii) about JS performance