Array.prototype.contains
Claude Pache
claude.pache at gmail.com
Thu Mar 6 17:09:02 PST 2014
Le 7 mars 2014 à 00:45, C. Scott Ananian <ecmascript at cscott.net> a écrit :
> And don't forget the related `DOMTokenList`, which is in
> Element.classList and thus used by everyone always.
>
Indeed, and there is also the (less known) `htmlFor` property of the <output> element, which is precisely a `DOMSettableTokenList`.
Since arraylike interfaces from the DOM uses `.contains()`, for the sake of consistency, the corresponding method on `Array.prototype` ought to be named `.contains()`. Sets are quite different from Arrays, so it is less important to have the same naming scheme as Sets than as all other arraylikes. (And another weaker reason to prefer `.contains()`: Maps and WeakMaps uses `.has()` for *keys*, and here we are talking about the *values* of an Array.)
—Claude
More information about the es-discuss
mailing list