raineorshine
7/19/2014 - 3:59 PM

Get the name of an object's constructor as a string. As described here: http://stackoverflow.com/questions/332422/how-do-i-get-the-name-of-a

Object.prototype.getName = function() { 
   var funcNameRegex = /function (.{1,})\(/;
   var results = (funcNameRegex).exec((this).constructor.toString());
   return (results && results.length > 1) ? results[1] : "";
};