Does it works for every browser?

----- Original Message ----- From: "gurdiga" <[email protected]>
To: "jQuery (English)" <[email protected]>
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