Re: Array.prototype.append ?

2018-05-23 Thread Isiah Meadows
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, 13:57 T.J. Crowder wrote: > On Wed, May 23, 2018 at 6:49 PM, Jordi Bunster

Re: es-discuss Digest, Vol 135, Issue 48

2018-05-23 Thread Andrea Giammarchi
Just one thought ... ```js Object.defineProperty(Array.prototype, "append", { value(...sources) { this.push(...[...sources]); return this; }, writable: true, configurable: true }); ``` ... but also another one ... ```js (array.push(...sources), array) ``` it seems

Re: es-discuss Digest, Vol 135, Issue 48

2018-05-23 Thread Tab Atkins Jr.
On Wed, May 23, 2018 at 1:05 PM, Jordan Harband 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

Re: es-discuss Digest, Vol 135, Issue 48

2018-05-23 Thread Jordan Harband
`array.push(...sources)`, not sure why we'd need "append". On Wed, May 23, 2018 at 1:25 PM, T.J. Crowder < tj.crow...@farsightsoftware.com> wrote: > On Wed, May 23, 2018 at 5:56 PM, Alexander Lichter wrote: > > An optimization would be great because in comparison to the

Re: Array.prototype.append ?

2018-05-23 Thread T.J. Crowder
On Wed, May 23, 2018 at 6:49 PM, Jordi Bunster wrote: > Cool! > > So for me, the point would be symmetry with Map and Set. Are you saying you'd want to have `append` on them as well? > As such my poly would go like so: > > ```js > Object.defineProperty(Array.prototype,

Re: Array.prototype.append ?

2018-05-23 Thread Jordi Bunster
Cool! So for me, the point would be symmetry with Map and Set. As such my poly would go like so: ```js Object.defineProperty(Array.prototype, "append", {     writable: true,     configurable: true,     value: function(arg) {     this.push(arg);     return this;     } }); ``` (Which is

Re: es-discuss Digest, Vol 135, Issue 48

2018-05-23 Thread T.J. Crowder
On Wed, May 23, 2018 at 5:56 PM, Alexander Lichter wrote: > An optimization would be great because in comparison to the existing concat > method, rest/spread is significantly slower at the moment (see > https://jsperf.com/single-array-composition) There's a limit to how much

Re: es-discuss Digest, Vol 135, Issue 48

2018-05-23 Thread Alexander Lichter
An optimization would be great because in comparison to the existing concat method, rest/spread is significantly slower at the moment (see https://jsperf.com/single-array-composition) On 23.05.2018 18:34, Ben Fletcher wrote: Does the `[...oldArr, ...elementsToPushArr]` pattern take care of

Re: es-discuss Digest, Vol 135, Issue 48

2018-05-23 Thread Ben Fletcher
Does the `[...oldArr, ...elementsToPushArr]` pattern take care of that for you? I've always assumed it's much less performant than your form would be, but I (naively) suppose the implementation could be optimized like anything else On Wed, May 23, 2018 at 8:01 AM

Re: Embarrassingly Simple Spec Question

2018-05-23 Thread T.J. Crowder
On Wed, May 23, 2018 at 1:29 PM, Isiah Meadows wrote: > That's the usual means of specifying precedence in anything remotely > like BNF. ;-) > > (IIUC It *could* be duplicated in *PrimaryExpression*, but it'd just > get unruly real quick if you were to try to expand

Re: Embarrassingly Simple Spec Question

2018-05-23 Thread Isiah Meadows
That's the usual means of specifying precedence in anything remotely like BNF. ;-) (IIUC It *could* be duplicated in *PrimaryExpression*, but it'd just get unruly real quick if you were to try to expand everything.) - Isiah Meadows m...@isiahmeadows.com www.isiahmeadows.com On Tue, May