I use prototypejs Class API for class-based OOP.
Is there a way to get the class name of an an object?
EG:
var myDog = new Dog();
myDog.getClassName() //Should return "Dog"
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you are using Prototypejs’
create()function to create the class, you need to store an additional property to hold the name of the class, since the only reference to a class namedDogis the variable name to which you assign the result ofcreate():On the other hand, if you are defining your class with something along these lines:
Then, you could just use
Object#constructor: