Changes between Version 17 and Version 18 of WebInspectorCodingStyleGuide


Ignore:
Timestamp:
Sep 18, 2015 9:43:19 AM (6 years ago)
Author:
BJ Burg
Comment:

update arrow function guidance

Legend:

Unmodified
Added
Removed
Modified
  • WebInspectorCodingStyleGuide

    v17 v18  
    8484Never use option (1), because it is a special case that only applies when the function has one argument, reducing predictability.
    8585
    86 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) (with braces if the arrow function is inlined).
     86In 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.
    8787
    8888In cases where the expression computes a value (a + 42) or performs a side effect (++a), prefer option (4).
     
    9898
    9999{{{
    100 setTimeout(() => { testRunner.notifyDone() }, 0); // return value not used
     100setTimeout(() => { testRunner.notifyDone() }, 0); // return value not implicitly returned
     101}}}
     102
     103
     104{{{
     105setTimeout(() => testRunner.notifyDone(), 0); // implicit return value not used
    101106}}}
    102107
     
    141146}}}
    142147
     148=== Bugs and Gotchas
     149
     150 * <https://bugs.webkit.org/show_bug.cgi?id=149338> Currently, arrow functions will always capture lexical `this`, even if the arrow function does not actually use `this`. The behavior causes TDZ error if such an arrow function is used in a constructor before calling `super()`.
     151 * Only basic functionality is implemented. Lexical binding of `arguments`, `super`, `new.target`, and `toString` are unimplemented.
     152
     153The feature tracking bug tree is here: <https://bugs.webkit.org/showdependencytree.cgi?id=140855&hide_resolved=1>
     154
     155
    143156== New class skeleton
    144157