Function length

Erik Arvidsson erik.arvidsson at
Sat Jun 9 23:39:44 PDT 2012

On Sat, Jun 9, 2012 at 9:08 PM, Rick Waldron <waldron.rick at> wrote:
> I just noticed strange behavior in spider monkey implementation of rest
> arguments:
> (function(a, b, {}).length // => 2
> I agree that this is strange, I would expect 3, as there are three formally
> named parameters.

The length in ES5 is not very consistent.

For ES6 we decide that we wanted the function length to be used to
tell how many required parameters a function has.

Today rest params are done using arguments:

(function(a, b) {
  var rest =, 2);
}).length  // => 2

The rule is that optional and rest parameters are not included in the
length of the function.


More information about the es-discuss mailing list