for(i=start; i for(i=start; i for(i=start; i all[i]);
}
substring("eclipse", 1, 4); //clip
function substring(all, start, end) {
[start];
}
else {
return all[start] substring(all, start 1, end);
substring("eclipse", 1, 4); //clip
使用for迴圈存取物件屬性: name: "Morgan Jones",
- 7777",
email: "morgan.jones@example.com"
};
for (var propertyName in person) { console.log(propertyName ":" person[propertyName]);
}
找出循環數組內的資料: ["Person", "Age", "City"],
["Sue", 22, "San Francisco"],] ;
var i;
var rows=table.length;
for (r=0;r
var c; th var cells = table[r].length ;
var rowText = "";
for (c=0;c rowText {
rowText = " ";
}
}
}
}
🎜>結果:
Person Age City
Sue 22 San Francisco
Joe 45 Halifax使用break立刻退出循環, 適用於for和while循環.