Created
August 29, 2012 05:06
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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