There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -69,7 +69,10 @@ var jQuery = function( selector, context ) { | ||
push = Array.prototype.push, | ||
slice = Array.prototype.slice, | ||
trim = String.prototype.trim, | ||
indexOf = Array.prototype.indexOf; | ||
indexOf = Array.prototype.indexOf, | ||
|
||
// [[Class]] -> type pairs | ||
class2type = {}; | ||
|
||
jQuery.fn = jQuery.prototype = { | ||
init: function( selector, context ) { | ||
@@ -487,7 +490,7 @@ jQuery.extend({ | ||
type: function( obj ) { | ||
return obj == null ? | ||
String( obj ) : | ||
toString.call(obj).slice(8, -1).toLowerCase(); | ||
class2type[ toString.call(obj) ] || "object"; | ||
}, | ||
|
||
isPlainObject: function( obj ) { | ||
@@ -799,6 +802,11 @@ jQuery.extend({ | ||
browser: {} | ||
}); | ||
|
||
// Populate the class2type map | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jdalton
Member
|
||
jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { | ||
This comment has been minimized.
Sorry, something went wrong.
leeoniya
|
||
class2type[ "[object " + name + "]" ] = name.toLowerCase(); | ||
}); | ||
|
||
browserMatch = jQuery.uaMatch( userAgent ); | ||
if ( browserMatch.browser ) { | ||
jQuery.browser[ browserMatch.browser ] = true; | ||
Take a look at this: http://jsperf.com/declared-literal-vs-string-split-2
I've previously noted that literal syntax is twice as fast as the string split syntax.