Skip to content

Instantly share code, notes, and snippets.

@jaubourg
Forked from rkatic/README.md
Created February 16, 2010 10:18
Show Gist options
  • Save jaubourg/305434 to your computer and use it in GitHub Desktop.
Save jaubourg/305434 to your computer and use it in GitHub Desktop.
(function($){
var toString = Object.prototype.toString;
var class2type = {
"[object Boolean]": "boolean",
"[object Number]": "number",
"[object String]": "string",
"[object Function]": "function",
"[object Array]": "array",
"[object Date]": "date",
"[object RegExp]": "regexp"
};
$.typeOf = function( obj ) {
if ( !obj ) {
return obj === null ? "null" : typeof obj;
}
return class2type[ toString.call( obj ) ] || "object";
};
})(jQuery || window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment