Array.prototype.contains

Brendan Eich brendan at mozilla.org
Fri Nov 2 17:45:07 PDT 2012


Allen Wirfs-Brock wrote:
>> "has" for keys (and possibly values of a Set, to preserve the value mapped to boolean future option that forEach also supports), "contains" for values in arrays
>
> sounds ok, except we get the same issue for contains that we have for indexOf.  II guess the big thing with contains is that it can be applied no non-indexed collections (maps, sets, etc.).

I'm not sure there's enough of a problem with using contains (or 
indexOf) to justify splitting contains-names, which has its own problems 
(inconsistency with indexOf, also with other languages, _mutatis 
mutandis_, e.g. Java).

> Also any reason contains should be provided for WeakMap? I not seeing why it shouldn't be there too.

How about Map contains (as well as has)?

How about Set for that matter?

/be


More information about the es-discuss mailing list