Constructor Function: Listing names of attributes in the structure

J

John Geddes

If I create an object using a constructor function, and then specify
attributes using the format "this.attrib1 = 123;" - then it is easy
enough to list the VALUES (using a loop like "for thisAttrib in
thisObject"), but for faster debugging, I would like also to be able
to list the NAMES of the attributes using a similar loop.

Is there a way to reference the attribute name specified in the
"this." statement,
ie the "attrib1" bit of "this.attrib1 = 123;" ?

John Geddes
 
G

Geoffrey Summerhayes

If I create an object using a constructor function, and then specify
attributes using the format "this.attrib1 = 123;" - then it is easy
enough to list the VALUES (using a loop like "for thisAttrib in
thisObject"), but for faster debugging, I would like also to be able
to list the NAMES of the attributes using a similar loop.

Is there a way to reference the attribute name specified in the
"this." statement,
ie the "attrib1" bit of "this.attrib1 = 123;" ?

Not quite sure if this is what you're looking for,
but here's is one of my debugging routines:

function DebugObject(a)
{
for(var b in a)
DebugOutput('\n'+ b + ':' +a);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top