Array.prototype.reduce ( callbackfn [ , initialValue [ , thisArg ] ] )

Edward Lee edilee at mozilla.com
Sat Mar 21 10:26:27 PDT 2009

On Sat, Mar 21, 2009 at 11:57 AM, Brendan Eich <brendan at mozilla.com> wrote:
> Of course, all the other "array extras" are specified with a thisArg so
> consistency argues that reduce and reduceRight should be specified that way
> too.
> I had to remind myself of Dave's analysis/argument, cited in full above, to
> see why we didn't do that.
What exactly was Dave's argument for not including a thisArg? There's
a brief mention of multiple-optional-args-messiness, and then it talks
about a future where other "array extras" don't have a thisArg.

> So this would mean reduce takes one callback argument and two optional
> arguments: thisObject and init.
> Alternatively, we could just eliminate that extra "thisObject" argument,
>    arr.map(function(x,i,me) { return obj.method(x,i.me) })
vs arr.map(method.bind(obj) vs arr.map(method, obj)

> At this point I would rather we stand on precedent than waver or haver further.
Reasonable. (I'll just probably end up using bind for all the other
array extras ;))


More information about the Es-discuss mailing list