4 Matching Annotations
  1. Jun 2021
  2. May 2021
  3. Jun 2017
    1. Trailing commas are used in the book examples on purpose as it gives cleaner diffs for the code examples. You'll learn to enforce this rule in the Linting JavaScript chapter.

      Trailing commas in recent ES6 code has a purpose, and this is it. JS has supported trailing commas in array literals from the outset but with recent versions of the language, it has expanded support for them, in object literals (ECMAScript 5) and function parameters (ES 2017). The main use here, it seems, is cleaner diffs for code. There are caveats and gotchas. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Trailing_commas