mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
Use array.indexOf if available (speeds up modern browsers). Thanks to lrbabe and Andrea for the patch. Fixes #5160.
This commit is contained in:
parent
5ac2e0837c
commit
c07d15d5a2
@ -441,6 +441,10 @@ jQuery.extend({
|
||||
},
|
||||
|
||||
inArray: function( elem, array ) {
|
||||
if ( array.indexOf ) {
|
||||
return array.indexOf( elem );
|
||||
}
|
||||
|
||||
for ( var i = 0, length = array.length; i < length; i++ ) {
|
||||
if ( array[ i ] === elem ) {
|
||||
return i;
|
||||
|
Loading…
Reference in New Issue
Block a user