Ignoring arguments

Bob Myers rtm at gol.com
Sun May 29 17:46:36 UTC 2016

Eliding array elements is not "similar" to eliding function formal
parameters. The latter is extremely rare, hardly readable, confusing,
bug-prone, and unnecessary because there is already a "standard way" which
is to use any old parameter name you want:

function foo(UNUSED1, UNUSED2, x)

Most linters will not complain, or there are ways to shut them up if they

If you want to throw away an argument, just throw it away.

function skipFirstParam(fn) { return ((first, ...args) => fn(...args)); }

`[1,2,3,4].map(skipFirstParam(i => i));


Or use Renki's solution.


On Sun, May 29, 2016 at 9:23 PM, Cyril Auburtin <cyril.auburtin at gmail.com>

> Similarly to:
> `var [,x,,y] = [1,2,3,4,5,6];`
> I think it could be interesting to let a field empty in function arguments
> `[1,2,3,4].map( (,i) => i )`, `Array.from({length:10}, (,i) => i )`
> `function test(a,,b) { }`
> (but that would alter the current parsing, that doesn't allow it)
> Currently I often use `_` as a way to mark ignored fields, but when there
> are more than 1 you need another identifier. A standard way would be
> interesting rather
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160529/0445cb0b/attachment.html>

More information about the es-discuss mailing list