From: lrbabe Date: Wed, 11 Nov 2009 20:15:58 +0000 (-0500) Subject: Use array.indexOf if available (speeds up modern browsers). Thanks to lrbabe and... X-Git-Url: http://git.asbjorn.it/?a=commitdiff_plain;h=c07d15d5a26c5b5dc2af7b396a704784d5bede34;p=jquery.git Use array.indexOf if available (speeds up modern browsers). Thanks to lrbabe and Andrea for the patch. Fixes #5160. --- diff --git a/src/core.js b/src/core.js index cdd7851..611e536 100644 --- a/src/core.js +++ b/src/core.js @@ -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;