1 Matching Annotations
- Jun 2017
-
survivejs.com survivejs.com
-
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
-