@morningz - it wouldn't surprise me. Nonetheless, if it were up to me,
(which it's not), jQuery wouldn't use it until it becomes
standardized. Prototype, MooTools and other competitors all augment
native data types, and it drives me nuts. Respect for the environment
is one of the features of jQuery that I enjoy the most. My point is
this: the only benefit of checking for indexOf would be to add it if
needed, which jQuery *generally* doesn't do. I can't see forking the
code for $.inArray being worthwhile unless it brought serious speed
improvements.

On Aug 25, 9:15 am, MorningZ <morni...@gmail.com> wrote:
> "IMO, it doesn't belong in the core"
>
> I think I read somewhere that a check for that usage will be in 1.3.3
> core, but damned if I can find where I saw that stated
>
> On Aug 25, 9:59 am, KeeganWatkins <mkeeganwatk...@gmail.com> wrote:
>
>
>
> > it does not work in every browser. the purpose of jQuery and similar
> > libraries is to streamline development and create a (mostly)
> > consistent foundation to build on, regardless of browser. if you're
> > interested in gaining some performance, or just using the latest JS
> > features, i'd suggest implementing this yourself. IMO, it doesn't
> > belong in the core, but it would be easy to add.
>
> > something like this:
> > if (Array.prototype.indexOf) {
> >     $.inArray = function(elem, array) {
> >         return array.indexOf(elem);
>
> > }
>
> > because $.inArray is already a part of the core, you'd just be
> > replacing it where the native indexOf method exists on Arrays.
> > otherwise, you'd just be using the standard implementation. hope that
> > helps.
>
> > On Aug 24, 12:28 pm, "Cesar Sanz" <the.email.tr...@gmail.com> wrote:
>
> > > Does it works for every browser?
>
> > > ----- Original Message -----
> > > From: "gurdiga" <gurd...@gmail.com>
> > > To: "jQuery (English)" <jquery-en@googlegroups.com>
> > > Sent: Sunday, August 23, 2009 1:07 PM
> > > Subject: [jQuery] $.inArray optimisation
>
> > > > Hello,
>
> > > > The $.inArray function is defined in
> > > >http://jqueryjs.googlecode.com/svn/trunk/jquery/src/core.js
> > > > as:
>
> > > > inArray: function( elem, array ) {
> > > > for ( var i = 0, length = array.length; i < length; i++ ) {
> > > > if ( array[ i ] === elem ) {
> > > > return i;
> > > > }
> > > > }
>
> > > > return -1;
> > > > },
>
> > > > I'm wondering: would it be possible to take advantage of the built-in
> > > > indexOf method of the Array present in FF Javascript engines? Im
> > > > thinking of something like:
>
> > > >    if (typeof Array.prototype.indexOf === 'function') {
> > > >        return array.indexOf(elem);
> > > >    }
>
> > > > What do you think?

Reply via email to