|
QC Javascript : for inI'am learning Javascript with QC and wondering why this code return just one of the two properties of the Object "myObject" . var result = new Object(); var myObject= { posX:2, posY:3 }; function (__string outputString) main () { result.outputString=enumeration(myObject); return result } function enumeration(a) { var name; for(name in a){ return name } } i'am doing a mistake ?
|
because the
return name;
will put the !last! value to the output. When the enumartion runs first, the value will posy, but last the value will posy.see the comp bellow.
yes ! Thanks! Those machines never take any initiative ;) This lesson make my day :)
you're welcome ;)
and, it's a typo in my first comment
"the value will posX, but last the value will posy."
So with your change i can now list the 2 properties :
So here is my first loop ( i realize it's a very little step for the humanity ;) to list every property :
yanomano: I edited the formatting on your comment a bit so that it's easier to read. I hope you don't mind.
How can this assembly be utilized to display values? Looks very useful, but I don't know how to apply it.
Thanks chris....i'am just discovering the javascript code tag :)
I don't know if it is very useful, it was just a basic learning test to display properties of an object ;)
ah, understood. Thanks! I hope to learn Javascript, too.