for … in语句用于在对象的各个属性,或数组的各个元素之间循环
用法:
for (variable in object)
{ statements; }
<HTML>
<HEAD>
<SCRIPT LANGUAGE = "JavaScript">
color = new Array("红色","蓝色","绿色");
for (var prop in color){
var record = "color " ;
record+=prop+"="+color[prop] + "<BR>";
document.write(record);
}
</SCRIPT>
</HEAD>
</HTML>