Coding standards are everywhere, but few companies do well in coding standards. I can't help but want to talk about the importance of coding standards. I hope everyone can pay attention to it. When calling a function, there is no space between the function name and the left parenthesis.
There is no space between the function name and the parameter sequence. There is a space between all other syntax elements and the left parenthesis.
Use the small hump naming method as the naming rules for all variables and attributes.
Two spaces are used for indentation and single quotation marks are used.
Join an array. No quotation marks are required unless the key name contains spaces or invalid characters.
Do not merge statements for different purposes into one row.
Do not omit the semicolon at the end of a sentence, even if one row has only one statement.
Do not use the auto-increment (++) and auto-increment (--) operators, instead of the + = and-= operators.
Do not use the "Equal" (=) operator. Only the "strictly equal" (=) operator is used.
All variable declarations are placed in the function header.
All functions are defined before use.
Name constructors and callback functions as much as possible, so that you can see a clearer call stack during debugging.
Try to define all member functions in the constructor through the prototype, define the attributes in the constructor, and then use the new keyword to create an object for the constructor.
Avoid complex inheritance. If you want to inherit, use the inherits function in the util module whenever possible. For example, if A inherits B, it can be util. inherits (A, B ).
References:
Appendix B (BYVoid) of Node. js Development Guide)
Javascript programming style (Ruan Yifeng)