STATEMENT:
for...in
for (variable in object) {statements}
The for...in statement is used to iterate a declared variable over every
property in a specified object.
The code in the body of the for ... in loop is executed once for
each property.
The variable argument can be a named variable,
an array element, or a property of the object.
This example simply displays the names of all the properties
of the 'drink' object:
Code:
var i;
for(i in drink)
document.write(i + "<BR>");
You can also have a specified variable iterate over the values of
an object's properties by placing it between square brackets after
the object name. Expanding on the previous example, the following
code displays both the name of each property in the 'drink'
object and its value:
Code:
var i;
for(i in drink)
document.write(i + ": "
+ drink[i] + "<BR>");
Copyright 1999 by Infinite Software Solutions, Inc.
Trademark Information