Array.prototype.toggle

Augusto Moura augusto.borgesm at gmail.com
Fri Feb 7 14:33:51 UTC 2020


To me this is more a use case for using Set instead of arrays, the support
is already great and it can be polyfilled. Set is the right data structure
to verify if some element is or is not in a collection

Em sex., 7 de fev. de 2020 às 08:49, manuelbarzi <manuelbarzi at gmail.com>
escreveu:

> just a proposal to provide this functionality into array, allowing to add
> / remove items in a toggling mechanism shortcut, avoiding the need to do
> traversing to locate the indexes and remove them next (i.e. by means of a
> polyfill or any other approach).
>
> ```js
> [1, 2, 3, 2, 1].toggle(1) // mutates the original array removing 1,
> resulting in [2, 3, 2]
> ```
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>


-- 
Atenciosamente,

Augusto Borges de Moura
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20200207/73e36aa7/attachment.html>


More information about the es-discuss mailing list