aboutsummaryrefslogtreecommitdiffstats
path: root/src/core.js
diff options
context:
space:
mode:
authorSebi Burkhard <sebi.burkhard@gmail.com>2012-12-18 22:33:32 +0700
committerDave Methvin <dave.methvin@gmail.com>2012-12-23 15:41:56 -0500
commit5eec75e582d27e2d4f625f6be33eabad84f16239 (patch)
treec1f298994ab8e30a39de2da67a915ead093c4b81 /src/core.js
parentd8298046311e66a47424ec3f3cbe77e97bee3958 (diff)
downloadjquery-5eec75e582d27e2d4f625f6be33eabad84f16239.tar.gz
jquery-5eec75e582d27e2d4f625f6be33eabad84f16239.zip
Fix #13075. Optimize $.type by preferring `typeof`. Close gh-1089.
Also fixes browsers where `typeof RegExp === "function"`.
Diffstat (limited to 'src/core.js')
-rw-r--r--src/core.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/core.js b/src/core.js
index 5927d1936..3d5f4be3f 100644
--- a/src/core.js
+++ b/src/core.js
@@ -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 ) {