July 1998
Intermediate to advanced
1456 pages
65h 5m
English
for/in — NN 2 IE J1 ECMA 1
A variation of the regular for loop that can
extract the property names and values of an object.
for (varNameinobjectRef) {statements}
function showProps() {
objName = "image"
obj = document.images[0]
var msg = ""
for (var i in obj) {
msg += objName + "." + i + "=" + obj[i] + "\n"
}
alert(msg)
}Read now
Unlock full access