Brendan Eich brendan at
Fri Dec 30 15:26:44 PST 2011

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.


----- Original Message -----
From: "Rick Waldron" <waldron.rick at>
To: "Jason Orendorff" <jason.orendorff at>
Cc: "es-discuss" <es-discuss at>
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 > wrote: 

On Fri, Dec 30, 2011 at 6:58 AM, Xavier MONTILLET 
< at > wrote: 
> 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? 



es-discuss mailing list 
es-discuss at 

es-discuss mailing list
es-discuss at

More information about the es-discuss mailing list