PDA

View Full Version : attributes


ivanirjoao
07-25-2006, 10:01 AM
Hi,

How can I get attribute's name in a object.

Ex.: new Object({id:5, name:'Joćo'})

How can I know the name of the attributes that are inside the object?

like Java Reflection

Debug list all the properties of an object when I call Debug.inspect( object )

can anyone tell me how can I do that?

Joćo Kreuzberg

jks_pdx
07-25-2006, 01:55 PM
I think you are looking for the for..in idiom of JavaScript.

Try this:

var lObj = new Object({id:5, name:'Joćo'});
var lAttribute;

for (lAttribute in lObj)
{
Debug.write(lAttribute);
Debug.write(lObj[lAttribute]);
}

pathogen
07-25-2006, 03:04 PM
Try Debug.inspect(theObject)

ivanirjoao
07-25-2006, 06:31 PM
I tried for and I got the attributes

thanks...

Debug.inspect(object) only print on Debug window the attribute informations... and I need that on vars

thanks anyway