Spec. 1: Be sure to write down global variables, and try to implement various functions, repeating code, etc. into a function.
Advantages: It helps to read and maintain. Prevent variable contamination.
Spec 2: All functions, variables, semantics. Spec. 3: Do not omit the semicolon at the end of the sentence. Specification 4: Do not use equal "
= =", to use congruent
"= = = "
Original: JS is a weakly typed language, and equality causes the default implicit conversions: false = = 0 = True
Spec. 5: Try to put all the variables in the first line. Such as:
var i, J, arr = [], obj = {};
Advantages:
- Less code.
- To help you remember all the variables
- Prevent definition before using
- Provide a single place to find variables
Rule 6: Do not use the new command instead of the object.create () command. Rule 7: Do not use the self-increment (+ +) and decrement (-) operators, substituting + = and-=. Rule 8: Always use curly braces to represent chunks.
if(a + b === c){ //dosomething}
Javascript-Common Code specification