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

Igor Bukanov igor at mir2.org
Sat Mar 21 10:47:17 PDT 2009


2009/3/21 Edward Lee <edilee at mozilla.com>:
> On Sat, Mar 21, 2009 at 11:57 AM, Brendan Eich <brendan at mozilla.com> wrote:
...
>> 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)

The last line is no exact alternative to the previous one. In full one
would write:

  arr.map(obj.method.bind(obj)) or arr.map(obj.method, obj)

IMO this double-usage of obj looks strange compared with the closure
version even if the latter is too verbose.

Igor


More information about the Es-discuss mailing list