Rest parameter syntax

Herby Vojčík herby at
Tue Jun 12 08:49:03 PDT 2012

Felix Böhm wrote:
> Per definition, rest parameters always need to be at the end of a
> FormalParameterList. I was wondering if this limitation could be liftet.
> Use-case: Most SQL libraries for node support passing query arguments to
> the query function (so SQL injections are avoided). The usual syntax is
>"SELECT * FROM t WHERE foo=? AND cbar=?", "bar", "cfoo",
> function(err, row){…});
> The number of arguments passed after the query depends on the number of
> question marks inside the query. It would be nice when an implementation
> could simply write = function(query, ...params, cb){…} and avoid
> using the arguments object or Array#poping the last element of params.

BTW, isn't this possible with comprehensions in parameter list: = function (query, ...[...params, cb]) { /* body */ }

If yes, problem solved.

> This change would require two additions: Every Identifier past rest
> can't be another rest parameter or have a default value specified.


More information about the es-discuss mailing list