March 14, 2000 - Printing an Object's Properties
March 14, 2000 Printing an Object's Properties Tips: March 2000
Yehuda Shiran, Ph.D.
|
for...in
loop loops through the existing properties of a given object. It repeats a variable over all of the object's properties. Take a look at the following script segment:
var result = " ";
for (curProperty in document) {
result += "document." + curProperty + "
";
}
The script prints the properties belonging to the document object:
document.length
document.elements
document.forms
document.links
...
...
Learn more about the in
operator in Column 59, IE 5.5's New Operators.