Skip to content

Instantly share code, notes, and snippets.

@kflorence
Created August 29, 2012 05:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kflorence/3507025 to your computer and use it in GitHub Desktop.
Save kflorence/3507025 to your computer and use it in GitHub Desktop.
Enhanced version of jQuery.type that will return class names for user generated Objects
var getType = (function() {
var rFunctionName = /function ([^(]+)/;
return function( object ) {
var matches,
type = $.type( object );
if ( type == "object" ) {
matches = rFunctionName.exec( object.constructor.toString() );
if ( matches && matches.length > 1 ) {
type = matches[ 1 ].toLowerCase();
}
}
return type;
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment