Are function arguments with the value `undefined` "present"?
tschneidereit at gmail.com
Fri May 31 08:28:31 PDT 2013
On Fri, May 31, 2013 at 5:01 PM, Rick Waldron <waldron.rick at gmail.com>wrote:
> `undefined` is a valid initial value for Array.prototype.reduce.
> `undefined` will also trigger the default parameter, so this works until
> nothing is provided, which breaks Step 10.
I guess that's what my question boils down to: is `undefined` a valid
initial value? It probably has to be for backwards-compatibility reasons.
>> If, however, the value `undefined` means that the argument is present,
>> the signature should probably be:
>> `function ArrayReduce(callbackfn, ...rest)`
> With minor changes to steps 9 and 10, plus the addition of steps to check
> rest.length and then Get(rest, "0"), this would work. I suspect that Allen
> would prefer to craft some sort of spec mechanism, from this use case, for
> "is foo present" assertions throughout the spec.
That's what I'm using for the moment, and will probably continue using,
given the abovementioned conclusion regarding backwards-compatibility, yes.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss