Function.length and Default Parameters

Kevin Smith khs4473 at gmail.com
Fri Oct 12 07:15:16 PDT 2012


> Anything but optional and rest (as speced) is the simplest rule I can
> think of, except everything including rest, but no one wants that.
>

But the current spec does not say that.  It says stop counting at the first
default, which doesn't really tell anyone anything useful about the
function's signature.

    function f(a = 1, b, c, d, e, f) {}
    f.length === 0; // Huh?

Unless I'm misreading...?

"Simple" may be in the eye of the beholder, but I contend that the above is
surprising.

The problem is that length is not useful for reflection anyway. The
> right way forward is to provide a better reflection API that exposes
> all the relevant information about the parameters.
>

A better reflection API sounds good, but your statement that length is not
useful is demonstrably false.  API judgements aside, we know that it is
currently used with non-WTF results.

Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121012/c818e4cf/attachment-0001.html>


More information about the es-discuss mailing list