Trailing comma for function arguments and call parameters

Dmitry Soshnikov dmitry.soshnikov at
Thu Jul 3 15:52:55 PDT 2014


Will it makes sense to standardize a trailing comma for function arguments,
and call parameters?

We have it for Array and Object initialisers, and people like using them
for long lists with prediction of new items adding in the future:

var modes = [

var platforms = {

In a world-wide, all linters seems propose _not_ to use trailing commas
because of old IE bugs, when the `length` of an array is calculated
incorrectly (the trailing comma is considered as a "hole" element):

[1,].lenght; // 2 in older IE, 1 per ES5 spec

However, we some transform level, it's easy to use trailing commas (they
are just striped for IE), and people really like them, making an actual
style guide to use them: not only for convenience of adding new items in
the future, but to preserve better version control system's blame logs
(e.g. git, etc).

So in out internal system with such transforms, people started to ask,
whether we can have the same for function parameters and call arguments as
well? We have this implemented for another language we use -- HACK (version
of PHP), and it's also a style guide rule to use trailing comma there.

function register(
) { ... }


I responded that we can just implement own internal extension just yet,
since it's not standard, but thought -- whether ES will actually need it at
standard level?

Thing to note: rest params. After the rest there should be no trailing
comma in the function arguments list, but still can be in the call params.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list