Wanted: standard Array function to append an array's elements to another array

Mark S. Miller erights at google.com
Wed Jul 27 22:12:32 PDT 2011

On Wed, Jul 27, 2011 at 9:21 AM, David Flanagan <dflanagan at mozilla.com>wrote:

> Could you return this instead of undefined so that we can chain calls? For
> example:
>   a.pushAll(b).pushAll(c).sort()

We could debate the pros and cons of this sort of chaining convention in
general. However, in this case I think the more important issue is API
consistency. The JS built ins are not defined in this style. It would make
the API much less regular and predictable to have some use this chaining
convention while others -- especially similar others like push -- don't.

I think this applies whether pushAll were actually added to EcmaScript or if
it were added as part of a library that makes it appear as if it is an
additional built-in.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110727/3b45e50b/attachment.html>

More information about the es-discuss mailing list