On Wed, May 23, 2018 at 11:06 PM, Isiah Meadows <[email protected]> wrote: > > Since `Array.prototype.push` is variadic, I don't see how this would be any > improvement on the status quo (which isn't that bad to begin with).
On Wed, May 23, 2018 at 9:14 PM, Tab Atkins Jr. <[email protected]> wrote: > On Wed, May 23, 2018 at 1:05 PM, Jordan Harband <[email protected]> wrote: >> `array.push(...sources)`, not sure why we'd need "append". > > From the original email (a bit buried and hard to find due to broken > threading, admittedly): > >> Has anyone ever suggested Array.prototype.append as an Array.prototype.push >> which returns the array itself? > > The point is x.append(y) returning x, whereas x.push(y) returns y. With large arrays you can also run into a platform's stack size limit with a large number of arguments. I got curious, and unless [my test][1] is significantly flawed, that limit is definitely a factor. The test uses `dest.push.apply(dest, source)` and works in chunks of 10k entries, reporting the point at which it got a stack error: * Chrome v66: Between 120k and 130k entries * Firefox v60: 500k - 510k * Edge v41: 650k - 660k * IE11: 250k - 260k * IE8¹: 5.25M (!) - 5.26M Using `dest.push(...source)` [instead][2] gave the same numbers as above on Chrome, Firefox, and Edge. So two reasons: Returning the array, and not pushing (no pun) the limit. ~125k entries isn't all that many. -- T.J. Crowder ¹ *Hey, some people still have to support it (e.g., via transpilation) -- old embedded IE-based apps in large institutions, etc. I'm just glad not to be one of them.* [1]: http://output.jsbin.com/jeperatefi [2]: http://output.jsbin.com/sucokosipu _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

