The use of JS naming specification, reference specification, the use of unified coding standards to write code can improve the readability of JS code, conducive to later maintenance and expansion, conducive to team development.
Reference specification for JS code
JS code should be avoided embedded in the HTML file, and because of the use of a different *. JS file and then use <script src= "*. JS "></script> loading, because this can use the browser cache to avoid page refresh and reload, for the JS code is not necessary, but is to increase the amount of file transfer. It is suggested that the JS code is divided into multiple files, the advantage is that it can reduce the repeated calls caused by the JS code modification.
The principle of naming conventions is to achieve the most understandable meanings with the fewest letters.
Variable declaration:
In development, all variables must be declared before use, JavaScript does not have to do so, but it is recommended that you do this because it makes the code easy to read, and it is good to find out those variables that are compiled as global without a declaration.
When declaring a variable, place var at the top of the declaration, separate each variable into a single line, and annotate it later, in alphabetical order.
Also write more comments
JS naming specification, reference specification