SV: [thelist] Javascript array label index
Andreas Wahlin
Andreas.Wahlin at ufl.gu.se
Fri Sep 10 08:48:38 CDT 2004
<You are looking for the for...in syntax.
http://www.devguru.com/Technologies/ecmascript/quickref/for...in.html
>
Thanks a bunch Joshua! I also detected the enumerator object
http://www.irt.org/xref/Enumerator.htm
For the interested here is som (asp/javascript) code, I apologize for
the perhaps not entirely English variable names
// setup
var test = new Array();
test["snutte"] = "snutt";
test["snutt"] = "snutte";
// enumerator
var namn = new Enumerator(test);
while(!namn.atEnd()) {
Response.Write(namn.item());
namn.moveNext();
}
// end enumerator
// for...in
for (var namn in test)
Response.Write(namn);
Response.Write(test);
// end for...in
The for...in seems a bit like a shorthand for an enumerator. This brings
much better capabilites for all array fans (who probably knew all this
already)
Andreas
More information about the thelist
mailing list