GitHub Project
JavaScript
Types
References
Objects
Use {}
Do not use reserved words
Use computed property names
Use shorthand
Group shorthand
Arrays
Use []
Use push()
Use spread operator ...
Use from()
Destructuring(解構)
Use object destructuring
Use array destructuring
String
Use single quotes for string
Multiple lines when too many characters
Use template strings
Do not use eval()
Functions
Use function declarations
Do not declare functions in a non-function block
Never name a parameter arguments
Use default parameter syntax
Never use the Function constructor
Spacing
Never mutate parameters
Arrow Functions
Use arrow functions notation
Omit the braces(忽略大括號) and use the implicit(隱式) return
Constructors
Use class
Use extends for inheritance
Use return this
toString()
Modules
Use modules
Do not use wildcart imports
Do not export directly from imports
Iterators and Generators
Do not use iterators
Do not use generators for now (reserved)
Properties
Use dot notation
Use subscript notation []
Variables
Always use const
Use one const declaration per variable
Group all the const and let
Place yur variables in a reasonable place
Hoisted(變量聲明提升)
Instruction
Function expressions
Function declarations
More details
Comparison Operators & Equality
Conditional statements
Use shortcuts
More details
Blocks
Use braces
Closing braces
Comments
Function comments
Control statements
Helping comments
Header comments of files
Whitespace
One space
End files
Chain calling
Leave a blank line after blocks and before the next statement
Do not pad blocks with blank lines
Commas & Semicolons
Type Casting(類型轉換) & Coercion(強制多態)
Naming
Use camelcase
Use pascalcase
Use a leading underscore _
Do not save references to this
Name the file with the class name
Accessors
Use getVal() and setVal(val)
Use isVal() or hasVal()
Use get() and set()
Events
jQuery
Prefix $
Cache jQuery object
Use Cascading or parent > child
Performance of different selectors
Published with GitBook