Trailing comma for function arguments and call parameters

Dmitry Soshnikov dmitry.soshnikov at
Sat Jul 5 10:30:53 PDT 2014

On Fri, Jul 4, 2014 at 9:33 AM, Oliver Hunt <oliver at> wrote:

> On Jul 3, 2014, at 3:52 PM, Dmitry Soshnikov <dmitry.soshnikov at>
> wrote:
> > Hi,
> >
> > 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 = [
> >   read,
> >   write,
> > ];
> >
> > var platforms = {
> >   web,
> >   canvas,
> > };
> > ```
> I suspect, but brendan could tell us otherwise, that the allowance of
> trailing commas is a result of a bug in the _early_ _early_ days of JS,
> which then got matched by the wonders of bug for bug compat, and so became
> necessary for web compatibility.
Yeah, as mentioned, it for a long time was considered as a bad practice
because of inconsistency of implementations, and I have suspicions that
this perception of "early design mistake" was dictated by exactly those
inconsistencies, that made the feature useless and harmful. However, times
have changed: with a build/transform step the feature is turned into a very
useful one, and can safely be used across implementations, and e.g. in our
code base is a de-facto standard (you'll have a lint warning if you forget
the trailing comma -- by the described above reasons: better git blame, and
convenience of future items adding).

> Also, i’m not sure that your intended uses is sufficiently compelling to
> justify non-backwards compatible syntax (i’m not against adding new syntax,
> i just feel that it needs to have substantial benefits)
> Hence, i don’t think this should be extended to other constructs.
At the same time, yes, I completely agree, that for the language itself,
it's probably not good enough reason to extend the syntax. And still, for
the language itself, globally, we'll still have inconsistency of trailing
comma handling in legacy IE engines. So, yes, I think it's just better to
implement as a local extension if will be needed just yet. Just wanted to
bring it at least to double-check and clarify/confirm.

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

More information about the es-discuss mailing list