Honestly, inArray and arrayPosition are equally intuitive to me. If
the value has a position in the array, then it is, by definition, in
the array. inArray returning the array position is a similar check,
but with a more robust ouput. Again, as MorningZ said, you can simply
check it's value using a simple gt operator. I honestly don't care too
much about inArray returning a non-boolean value which may be
unintuitive to some users. After all, the docs are there for a
reason.

On Mar 23, 3:51 pm, Mike521 <mi...@favorfavor.com> wrote:
> I'm not discussing whether I can or can't use it the way it is, I'm
> discussing which way is more intuitive.
>
> On Mar 23, 3:18 pm, MorningZ <morni...@gmail.com> wrote:
>
> > just can't say
>
> > if ($.inArray("value", array) > -1) {
> >    // found in array?
>
> > }
>
> > On Mar 23, 2:59 pm, Mike521 <mi...@favorfavor.com> wrote:
>
> > > I was about to use inArray (http://docs.jquery.com/Utilities/
> > > jQuery.inArray) to determine if an element was in an array or not, but
> > > I realized I can't use it as a true/false response since it returns
> > > the position (and could return 0 if the element was found in position
> > > 0 - returns -1 if not found). I was expecting something with the same
> > > functionality as the PHP function in_array (http://us3.php.net/
> > > in_array)
>
> > > I know it's a minor point but wouldn't it be more intuitive if called
> > > arrayPosition? with a name like that I'd expect the functionality it
> > > has now.

Reply via email to