Added some tweaks to $.type to handle null and undefined. Added a bunch of unit tests as well.

This commit is contained in:
John Resig 2010-08-27 06:10:52 -07:00
parent 9ce1d09a0a
commit 5d2be7e299
2 changed files with 28 additions and 1 deletions

View file

@ -446,7 +446,11 @@ jQuery.extend({
},
type: function( obj ) {
return toString.call(obj).slice(8, -1).toLowerCase();
return obj === null ?
"null" :
obj === undefined ?
"undefined" :
toString.call(obj).slice(8, -1).toLowerCase();
},
isPlainObject: function( obj ) {