[Bug 23056] Function's length property is inconsistent with EcmaScript

https://www.w3.org/Bugs/Public/show_bug.cgi?id=23056

--- Comment #10 from Erik Arvidsson <arv@chromium.org> ---
This is pretty straightforward to spec in a way that matches ES6 without
resorting to ES6 syntax.

1. Let length be the number of parameters, including optional and rest
parameters.
2. For each parameter of the parameters list, iterating backwards:
   1. If the parameter is an optional parameter, let length be length - 1.
   2. Else if the parameter is a rest parameter, let length be length - 1.
   3. Else return length.
3. Return length.

If there are overloaded operations, return the smallest length.


Boris, ES6 defines undefined to be treated as the sentinel used for no
argument. This is important because a user can pass you undefined as a place
holder.

function f(y = 1) {
  return y;
}
assert(f(undefined) == 1);

function g(x = 1, y = 2) {
  return x + y;
}
assert(g(undefined, 5) == 6);

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Received on Wednesday, 28 August 2013 13:22:10 UTC