On Wed, May 23, 2018 at 6:49 PM, Jordi Bunster <jbuns...@microsoft.com>
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, "append", {
>     writable: true,
>     configurable: true,
>     value: function(arg) {
>         this.push(arg);
>         return this;
>     }
> });

For some reason, in my head you were calling `append` with an array, not
discrete items. Not sure why that was. Silly of me. I've rarely needed an
`append` for individual items, my use cases have generally been appending
an array to another array. But that could be its own separate thing
(`appendArray`). (I **wouldn't** overload it as with `concat`.)

I'd lean toward accepting as many as are given, as with `push`:

```js
Object.defineProperty(Array.prototype, "append", {
    value: function(...items) {
        for (let i = 0, len = source.length; i < len; ++i) {
            this.push(item[i]);
        }
        return this;
    },
    writable: true,
    configurable: true
});
```

-- T.J. Crowder
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to