If you use Prototypejs create() to create a class, you need to save an additional property to keep the class name, since the only reference to the class named Dog is the name of the variable to which you assign the result of create() :
var Dog = Class.create({ className: "Dog", initialize: function() { } }); var myDog = new Dog(); console.log(myDog.className);
On the other hand, if you define your class with something like this:
function Dog() { }
Then you can just use Object#constructor :
myDog.constructor.name; // "Dog"
source share