Array.prototype.contains

Domenic Denicola domenic at domenicdenicola.com
Wed Jul 23 09:44:40 PDT 2014


Yes. Everyone agrees .contains is good. It will happen.

There was some debate about .has vs. .contains, but from what I recall I was one of the only people pushing for .has, and I have since changed my mind.

I am hopeful in fact that .contains is so simple and uncontroversial that we can push it through the post-ES6 spec process very quickly, including into implementations.

From: es-discuss [mailto:es-discuss-bounces at mozilla.org] On Behalf Of Will Ray
Sent: Wednesday, July 23, 2014 12:42
To: Maël Nison
Cc: Brendan Eich; es-discuss at mozilla.org
Subject: Re: Array.prototype.contains

Additionally, .contains() can be used in a conditional statement directly, while .indexOf() requires the result of a comparison with -1 (or a bitwise inversion, which is not terribly intuitive). It's just more room for simple typos.

Will Ray

On Wed, Jul 23, 2014 at 5:29 AM, Maël Nison <nison.mael at gmail.com<mailto:nison.mael at gmail.com>> wrote:
Isn't replacing DOMStringList a different issue than adding Array.prototype.contains ?

Using indexOf is possible, but a .contains() method would give a stronger notice of intent when reading code.

On 7 March 2014 15:11, Boris Zbarsky <bzbarsky at mit.edu<mailto:bzbarsky at mit.edu>> wrote:
On 3/6/14 6:15 PM, Joshua Bell wrote:
FWIW, Blink uses DOMStringList only in IndexedDB and apparently in
Location.ancestorOrigins

Indeed.  And Location.ancestorOrigins is fairly new and not broadly implemented, so I don't expect its behavior to be a strong compat constraint.

So I guess that leaves us with a few questions:

1)  Is it still early enough in the indexeddb world that we can change the thing it uses from DOMStringList to Array.  And if so whether that's a change we want to make.

2)  If we want to keep the non-writing behavior for indexeddb or for some other reason (insufficiently flexible bindings systems?) can't switch ti to Array for now, can we just remove item() and contains() from DOMStringList to make the switch easier later?


-Boris
_______________________________________________
es-discuss mailing list
es-discuss at mozilla.org<mailto:es-discuss at mozilla.org>
https://mail.mozilla.org/listinfo/es-discuss



--
Maël Nison (arcanis<https://twitter.com/arcanis>)
Frontend Developer @ Sketchfab



_______________________________________________
es-discuss mailing list
es-discuss at mozilla.org<mailto: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/20140723/dafab6b5/attachment.html>


More information about the es-discuss mailing list