PDA

View Full Version : how to get a class name


yang_dx
09-20-2005, 07:08 PM
i have an instance of some class, how can i get its class name? the "typeof()" function always return "Object" but not the exact class name.
thanks for help!

dionatan
09-20-2005, 07:49 PM
You can use the atribute classroot to find the 'typeof' your instance.

yang_dx
09-20-2005, 09:46 PM
thanks,
but i think the classroot is still an instance of a class,
what i want is a string which is the class name but not the instance name.

alexander
09-20-2005, 11:07 PM
try using "className" like

if( someObject.className == "MyClass" )

Alexander

yang_dx
09-21-2005, 04:51 AM
i tried the className property, but it's an undefined.
any other ideas?

bstow01
04-27-2007, 04:59 PM
myObj.toString() will get you the name of the class

sushil
04-28-2007, 05:20 AM
<canvas height="180" width="500" debug='true'>
<class name="tt" bgcolor='red'/>
<script>
var ss=new tt(canvas,{x:20,y:20,width:100,height:100})
Debug.write("classname "+ss.classname);
</script>
</canvas>