For/In 循环
JavaScript for/in 语句循环遍历对象的属性:
实例
var person={fname:"John",lname:"Doe",age:25};
for (x in
person)
{
txt=txt + person[x];
}
实例:
for (var i=0,len=cars.length;
i<len; i++)
{
document.write(cars[i] + "<br>");
}
时间: 2024-11-01 03:48:30