# Let Set.prototype.add() accept multiple args like Array.prototype.push()

**URL:** <https://es.discourse.group/t/let-set-prototype-add-accept-multiple-args-like-array-prototype-push/404>\
**Category:** 💡 Ideas\
**Tags:** proposal\
**Created:** [July 22, 2020, 8:05pm UTC](https://es.discourse.group/t/let-set-prototype-add-accept-multiple-args-like-array-prototype-push/404 "2020-07-22T20:05:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JackWorks](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/jackworks/32/260_2.png) [@JackWorks](https://es.discourse.group/u/JackWorks)\
**Post date:** [July 22, 2020, 8:05pm UTC](https://es.discourse.group/t/let-set-prototype-add-accept-multiple-args-like-array-prototype-push/404/1 "2020-07-22T20:05:56Z")

</div>

Let Set.prototype.add() accept multiple args like Array.prototype.push()

---

<div class="post-metadata">

**Author:** ![AshleyScirra](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ashleyscirra/32/125_2.png) [@AshleyScirra](https://es.discourse.group/u/AshleyScirra)\
**Post date:** [July 23, 2020, 10:24pm UTC](https://es.discourse.group/t/let-set-prototype-add-accept-multiple-args-like-array-prototype-push/404/2 "2020-07-23T22:24:53Z")

</div>

If we do this, please let's not reinvent the [nasty gotcha with Array.prototype.push()](https://es.discourse.group/t/array-method-to-append-another-array-in-place/98) where you get implementation-specific limits on the number of arguments you can push because it transfers everything on the stack.

I think there should be separate `pushAll()` and `addAll()` methods that accept an array or iterable, rather than relying on multiple arguments.

---

<div class="post-metadata">

**Author:** ![claudiameadows](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/claudiameadows/32/126_2.png) [@claudiameadows](https://es.discourse.group/u/claudiameadows)\
**Post date:** [July 28, 2020, 9:15am UTC](https://es.discourse.group/t/let-set-prototype-add-accept-multiple-args-like-array-prototype-push/404/3 "2020-07-28T09:15:47Z")

</div>

Personally, I'd rather both to exist. Multi-arg `set` and `push` are useful in their own right (though `add` does (un)helpfully return `this` - I wish it returned whether the key was already present instead), and can be really fast as they require minimal allocation. Iterable-driven `pushAll`/`addAll` have their own uses, too, as they efficiently deal with large collections of values without polluting the stack and can be much more straightforwardly translated to `memcpy`.

Currently, I exclusively use `.push`, but I never use `.push(...values)` unless `values` is itself a rest parameter or in the fleetingly rare event where it actually provides a noticeable performance boost (which I've encountered maybe once ever).

---

<div class="post-metadata">

**Author:** ![yuval-a](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/yuval-a/32/2355_2.png) [@yuval-a](https://es.discourse.group/u/yuval-a)\
**Post date:** [January 18, 2025, 10:33pm UTC](https://es.discourse.group/t/let-set-prototype-add-accept-multiple-args-like-array-prototype-push/404/4 "2025-01-18T22:33:47Z")

</div>

I was just writing this proposal and saw this. I strongly support this.  
What can I do to help promote it further?
