Created
June 29, 2013 09:32
-
-
Save simonewebdesign/5890526 to your computer and use it in GitHub Desktop.
How do I get the name of an object's type in JavaScript? http://stackoverflow.com/questions/332422/how-do-i-get-the-name-of-an-objects-type-in-javascript
This file contains 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
Object.prototype.getName = function() { | |
var funcNameRegex = /function (.{1,})\(/; | |
var results = (funcNameRegex).exec((this).constructor.toString()); | |
return (results && results.length > 1) ? results[1] : ""; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment