On Thu, Feb 23, 2012 at 12:35 PM, Mark S. Miller <[email protected]> wrote:

>     if (arr.contains(foo)) {
>
> vs
>
>     if (arr.indexOf(foo) !== -1) {

The readability of the above two options is very different. The first
option is far superior as it expresses what the programmer wants to
know. The second options is an expression of how it can be
accomplished and requires understanding of indexOf's return values.

I think the addition Array.prototype.contains would be a good, simple
one that would improve programs. The fact that this function exists in
libraries means it is useful in a general in the opinion of at least
several programmers.

Peter
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to