循環(huán)可以將代碼塊執(zhí)行指定的次數(shù)。
如果您希望一遍又一遍地運(yùn)行相同的代碼,并且每次的值都不同,那么使用循環(huán)是很方便的。
我們可以這樣輸出數(shù)組的值:
document.write(cars[0] + "
"); document.write(cars[1] + "
"); document.write(cars[2] + "
"); document.write(cars[3] + "
"); document.write(cars[4] + "
"); document.write(cars[5] + "
");
不過通常我們這樣寫:
for (var i=0;i
![]() | ![]() .. 定價(jià):¥45 優(yōu)惠價(jià):¥42 更多書籍 |
![]() | ![]() .. 定價(jià):¥225 優(yōu)惠價(jià):¥213 更多書籍 |