> for (var p in myObject) {
> document.forms[0].elements['out'].value +=
[quoted text clipped - 18 lines]
> document.forms[0].elements['out'].value+= props[i];
> }
fine thanks a lot !
but, when u do :
var p in myObject
p is all the properties, does that include methods ?
or, as in ruby (somehow) a method could be a property of the object ?

Signature
une bévue
VK - 30 Sep 2006 19:22 GMT
> p is all the properties, does that include methods ?
> or, as in ruby (somehow) a method could be a property of the object ?
For the answer you could try this on say window object ;-)
Yes, "property" term here includes fields, properties (aka compound
properties with getter/setter) and methods. So this term is not an
exact equivalent of similar term used in some programming languages.
Think of it as "anything enumerable this object has".
You can write a full-scaled object walker with additional sortouts of
any complexity.
var props = new Array();
var desc = '';
for (var p in myObject) {
desc = myObject[p] + ' = ' + p + '\n';
desc+= myObject.hasOwnProperty(p) ?
'own ' : 'inherited ';
// methods reported as objects by IE and as functions by others:
desc+= ((typeof p == 'function') || (typeof p == 'object)) ?
'method\n\n' : 'property\n\n';
props.push(myObject[p] + ' = ' + p + '\n');
}
props.sort();
and further...
VK - 30 Sep 2006 19:26 GMT
> // methods reported as objects by IE and as functions by others:
> desc+= ((typeof p == 'function') || (typeof p == 'object)) ?
> 'method\n\n' : 'property\n\n';
>
> props.push(myObject[p] + ' = ' + p + '\n');
sorry, typed of my head... Of course this has to be changed:
props.push(desc);
VK - 30 Sep 2006 19:45 GMT
> > // methods reported as objects by IE and as functions by others:
> > desc+= ((typeof p == 'function') || (typeof p == 'object)) ?
[quoted text clipped - 5 lines]
>
> props.push(desc);
And thinking it over again :-) that would kill the branching, so in
case if some property is in turn an object with its own properties,
the walker will report it as "method" which is plain wrong. Because of
IE's ambigousity (both method and object reported as "object") you have
to think for a workaround; and then make your walker recursive for
branches, but it's getting on the industry level already, not a
quick'n'durty helper :-)
Une bévue - 30 Sep 2006 19:56 GMT
> sorry, typed of my head... Of course this has to be changed:
ok, fine, thanks !

Signature
une bévue