Array.prototype.contains

Greg Smith greg at bocoup.com
Tue Jan 3 06:49:21 PST 2012


Sorry I meant Array.prototype.contains

On Tue, Jan 3, 2012 at 9:46 AM, Greg Smith <greg at bocoup.com> wrote:

> I see Array.contains as a great idea. This is an operation I use
> constantly when I write code and it'd be nice to have it be a first class
> Array operation. Sure it's not so different than indexOf, but the semantics
> are much more intuitive and it may very well be the more common operation.
>
> -Greg
>
>
> On Fri, Dec 30, 2011 at 6:29 PM, Rick Waldron <waldron.rick at gmail.com>wrote:
>
>> That's what I figured - I guess I thinking of implementations that would
>> be ES3 & 5 compat
>>
>> Thanks!
>>
>>
>> On Fri, Dec 30, 2011 at 6:26 PM, Brendan Eich <brendan at mozilla.com>wrote:
>>
>>> Jason doesn't want a wrapper written in JS that depends on the current
>>> value of this.indexOf, I think. That's enough reason for a built-in. This
>>> is a no-brainer for ES6 IMHO.
>>>
>>> /be
>>>
>>> ----- Original Message -----
>>> From: "Rick Waldron" <waldron.rick at gmail.com>
>>> To: "Jason Orendorff" <jason.orendorff at gmail.com>
>>> Cc: "es-discuss" <es-discuss at mozilla.org>
>>> Sent: Friday, December 30, 2011 2:28:28 PM
>>> Subject: Re: Array.prototype.contains
>>>
>>>
>>>
>>> On Fri, Dec 30, 2011 at 5:24 PM, Jason Orendorff <
>>> jason.orendorff at gmail.com > wrote:
>>>
>>>
>>>
>>> On Fri, Dec 30, 2011 at 6:58 AM, Xavier MONTILLET
>>> < xavierm02.net at gmail.com > wrote:
>>> > http://wiki.ecmascript.org/doku.php?id=harmony:string_extras
>>> > There is a proposal for String.prototype.contains so why can't I find
>>> > one for Array.prototype.contains?
>>>
>>> No kidding. I need this method every time I write ECMAScript code.
>>> What I want is like:
>>>
>>> Object.defineProperty(Array.prototype, "contains", {
>>> configurable: true,
>>> writable: true,
>>> value: function contains(x) {
>>> return this.indexOf(x) !== -1;
>>> }
>>> });
>>>
>>> except without the property lookup for indexOf.
>>>
>>>
>>>
>>> At this.indexOf ? Or the whole "this.indexOf(x) !== -1;" lookup? How
>>> else could it work?
>>>
>>>
>>> Rick
>>>
>>>
>>>
>>> -j
>>>
>>>
>>> _______________________________________________
>>> es-discuss mailing list
>>> es-discuss at mozilla.org
>>> https://mail.mozilla.org/listinfo/es-discuss
>>>
>>>
>>> _______________________________________________
>>> es-discuss mailing list
>>> es-discuss at mozilla.org
>>> https://mail.mozilla.org/listinfo/es-discuss
>>>
>>
>>
>> _______________________________________________
>> 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/20120103/407d0dd6/attachment.html>


More information about the es-discuss mailing list