- Never ever use tabs to indent, always 2 spaces
- Indent continued lines 2 spaces
- Avoid semicolons unless necessary
- Prefer multiple
varstatements over leading, - Use trailing commas in arrays and objects
- Use namespaces, don't clutter global namespace unless necessary
- Use
CamelCasefor prototypes,smallCamelCasefor variables and functions,SCREAMING_SNAKE_CASEfor constants - Avoid functions with more than 15 lines
- Avoid prototype definitions with more than 200 lines
- Avoid functions with more than 4 parameters
- Avoid functions with more than 3 return values in callback
- Prefer single quotes for strings
- Prefer an asynchronous workflow over a synchronous one
- Avoid more than 3 nested callbacks
- Never pass
setTimeouta string to call - Use
returnas early as possible - Use named closures if it adds value
- Use events freely