Changes between Version 24 and Version 25 of WebInspectorCodingStyleGuide
- Timestamp:
- Jan 2, 2017 1:20:43 PM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
WebInspectorCodingStyleGuide
v24 v25 15 15 * Calling a constructor with no arguments should have no parenthesis `'()'`. eg. `var map = new Map;` 16 16 * Put anonymous functions inline if they are not used as a subroutine. 17 * Prefer `let` to `var`, unless the variable is not used in a block scoping manner. Be careful when using `let` with `case` switches, as [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_dead_zone_and_errors_with_let all switch cases share the same block by default]. 17 18 * Use arrow functions when possible, unless it makes code less readable. See below for examples. 18 19 * For default parameters, add a space around the default assignment: `function foo(isGood = false)` … … 88 89 Never use option (1), because it is a special case that only applies when the function has one argument, reducing predictability. 89 90 90 In cases where the return value is used and the expression is a constant ("foo"), a variable (foo), or a member (this.foo), use option (2). Never use braces though, because implicit return only works if there are no braces around the single expression.91 In cases where the return value is used and the single expression is a constant ("foo"), a variable (foo), a member (this.foo), or evaluates to a Promise, use option (2). Never use braces though, because implicit return only works if there are no braces around the single expression. 91 92 92 93 In cases where the expression computes a value (a + 42) or performs a side effect (++a), prefer option (4).