Set.prototype.toggle

Isiah Meadows isiahmeadows at gmail.com
Sun Oct 29 23:59:06 UTC 2017


And for these general kinds of uses, I've almost always found booleans
better and easier than anything else - negation is literally toggling.
`classList.toggle` is probably the only exception I regularly run into.

On Sun, Oct 29, 2017, 17:06 Andrea Giammarchi <andrea.giammarchi at gmail.com>
wrote:

> > having an API with a boolean argument - which is something that there's
> zero precedent in the language
>
> not sure about strictly JS but `classList`, which is a Set of strings, has
> a `classList.toggle(name, true)` which does the same.
>
> although I agree this is a not so needed method so it's probably not worth
> to have a precedent in the JS side
>
>
>
>
>
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20171029/c18b1678/attachment.html>


More information about the es-discuss mailing list