Javascript coding style basic rules.
Some basic rules for making javascript code style very simple in ES6.
- 2 spaces – for indentation
- Single quotes for strings – except to avoid escaping
- No unused variables
- No semicolons
- Space after keywords
if (condition) { ... } - Space after function name
function name (arg) { ... } - Always use
===instead of==– butobj == nullis allowed to checknull || undefined. - Always handle err function parameter in Node.js
- Use ES6 features like arrow functions, template strings, rest operator, argument spreading, generators, promises, maps, sets, symbols, etc.