Commit c07d15d5 authored by lrbabe's avatar lrbabe Committed by John Resig

Use array.indexOf if available (speeds up modern browsers). Thanks to lrbabe...

Use array.indexOf if available (speeds up modern browsers). Thanks to lrbabe and Andrea for the patch. Fixes #5160.
parent 5ac2e083
...@@ -441,6 +441,10 @@ jQuery.extend({ ...@@ -441,6 +441,10 @@ jQuery.extend({
}, },
inArray: function( elem, array ) { inArray: function( elem, array ) {
if ( array.indexOf ) {
return array.indexOf( elem );
}
for ( var i = 0, length = array.length; i < length; i++ ) { for ( var i = 0, length = array.length; i < length; i++ ) {
if ( array[ i ] === elem ) { if ( array[ i ] === elem ) {
return i; return i;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment