First, some write code considerations
Use of 1.parseInt
Because in octal, 8 and 9 are not numbers, so
Generates 0 as a result, which causes the program parsing time and date to appear incorrectly. Therefore, it is recommended to use parseint to pass 10.
The result of parseint ("08", 10) is 8
2. When using the for in loop, it is best to add
for inch obj) { if (Obj.hasownproperty (MyVar)) {
}
}
To rule out the properties from the prototype chain.
3. How to determine whether a value is a number
var isnumber = function Isnumber (value) { return typeof value = = = ' Number ' && isfinite (value);}
4. Use
If (ok) { t = true; }
Replace
if (OK) T = true;
5. Use
var foo = function foo () {};
Replace
function foo () {};
6. In addition to the for function if switch try while, All statements are followed by a semicolon.
7. Do not exceed 100 words per line of code, beyond the line to be wrapped. Line breaks after punctuation and operators.
8. Use + = 1-=1 instead of + +--
Read the "JavaScript language essence" note