Trailing comma for function arguments and call parameters

Oliver Hunt oliver at apple.com
Fri Jul 4 09:33:46 PDT 2014


On Jul 3, 2014, at 3:52 PM, Dmitry Soshnikov <dmitry.soshnikov at gmail.com> 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.

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.

—Oliver


More information about the es-discuss mailing list