eric at ericleads.com
Wed Mar 5 01:42:08 PST 2014
According to the thread:
>* On Thu, Feb 23, 2012 at 3:15 PM, Erik Arvidsson <erik.arvidsson at gmail.com <https://mail.mozilla.org/listinfo/es-discuss>>
>* DOM4 added a new interface called DOMStringList for the sole reason
*>* that Array does not have contains. Before this the return type was an
*>* Array of Strings so we could use indexOf, map, forEach etc. Now that
*>* it is using a non Array we lost all of that.
> *We (WebKit) used to return a true JS Array (created by JSC or V8).
On Wed, Mar 5, 2014 at 2:07 AM, David Bruant <bruant.d at gmail.com> wrote:
> Le 05/03/2014 09:24, Eric Elliott a écrit :
> What ever happened to Array.prototype.contains? There's an old strawman
> for Array.prototype.has (
> http://wiki.ecmascript.org/doku.php?id=strawman:array.prototype.has )
> that references this thread: (
> https://mail.mozilla.org/pipermail/es-discuss/2012-February/020745.html )
> Let's try to add it to the next meeting agenda
> But it seems the thread fizzled out a couple years ago, and
> Array.prototype.contains didn't seem to make its way into ES6. That seems
> odd, since we do have String.prototype.contains, and it seemed like it was
> desirable for DOM.
> The DOM won't inherit from it directly, shall it?
> It's also a standard utility function in several libraries.
> Was it left out on purpose? If so, what was the justification?
> I predict code like this without it:
> ''.contains.call([1, 2, 3], 2); // true
> .indexOf === -1 works today for this use case and will continue to.
> I'd be happy to see !~arr.indexOf(el) disappear in favor of a use of
> .contains() though.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss