Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.
PLease have a look into this link .hope you can find the answer
http://stackoverflow.com/questions/1249531/how-to-get-a-javascript-objects-class
I assume that you are looking to get class name from an object variable.
e.g.
function Foo() {... ... ... ... ... ... ... }
var myFoo = new Foo();
Now you have myFoo and what you want is "Foo".
The simple thing that will work here is:
var strClassname = myFoo.constructor.name;
//here strClassname will hold value "Foo" as string
There is a very good disussion done for this@
http://stackoverflow.com/questions/1249531/how-to-get-a-javascript-objects-class
Kindly have a look on following articles:
- http://stackoverflow.com/questions/332422/how-do-i-get-the-name-of-an-objects-type-in-javascript
- http://stackoverflow.com/questions/1249531/how-to-get-a-javascript-objects-class
In JavaScript, every object has a constructor property, which contains a Function object, which has a name property, which contains a string
obj.constructor.name