Array.prototype.contains

Asen Bozhilov asen.bozhilov at gmail.com
Fri Nov 2 12:22:04 PDT 2012


Erik Arvidsson


>
> If we call it "has", should we also rename String.prototype.contains?
>
>
>
Most of the JS libraries use `has` method for checking property and key
existence. I am wondering if there is Array.prototype.has how they would
overload their `has` methods to work as expected with arrays, array-like
and regular native objects.  Also their is and
Object.prototype.hasOwnProperty. For example this code is a little bit
confusing for me:

var arr = [1, 2, 3];
arr.hasOwnProperty(0); //true
arr.has(0); //false
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121102/feb7eda2/attachment.html>


More information about the es-discuss mailing list