Some responses to these, inline. -----
Isiah Meadows m...@isiahmeadows.com www.isiahmeadows.com On Thu, May 24, 2018 at 3:33 AM, T.J. Crowder <tj.crow...@farsightsoftware.com> wrote: > On Wed, May 23, 2018 at 11:06 PM, Isiah Meadows <isiahmead...@gmail.com> > 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. <jackalm...@gmail.com> wrote: >> On Wed, May 23, 2018 at 1:05 PM, Jordan Harband <ljh...@gmail.com> 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. @Jordan, `x.push(y)` returns `x.length` (specifically, the new length). > > 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 Wait, what? Of all things old IE screws up, this isn't one of them? > > 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. Was the proposal `for (const i of y) x.push(y)`, like a mutable `concat`? I interpreted it as basically `x.push(y); return x` from the start, hence why I didn't see the point. Adding a mutable `concat` variant *would* be useful, though, enough that I'd like to see it happen. Add an optional mapping callback like with `Array.from`, and I'd be set. But in this case, I'd rather it be named `Array.prototype.pushAll`, not `Array.prototype.append`. [1] [1]: https://github.com/isiahmeadows/array-additions-proposal#arrayprototypepushallitems > > -- 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 es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss