Fix #13075. Optimize $.type by preferring typeof. Close gh-1089.

Also fixes browsers where `typeof RegExp === "function"`.
This commit is contained in:
Sebi Burkhard
2012-12-18 22:33:32 +07:00
committed by Dave Methvin
parent d829804631
commit 5eec75e582
2 changed files with 17 additions and 4 deletions

View File

@@ -427,9 +427,12 @@ jQuery.extend({
},
type: function( obj ) {
return obj == null ?
String( obj ) :
class2type[ core_toString.call(obj) ] || "object";
if ( obj == null ) {
return String( obj );
}
return typeof obj === "object" || typeof obj === "function" ?
class2type[ core_toString.call(obj) ] || "object" :
typeof obj;
},
isPlainObject: function( obj ) {