JavaScript中的循環(huán)用來將同一段代碼執(zhí)行指定的次數(shù)(或者當指定的條件為true時)。 JavaScript 循環(huán) 在編寫代碼時,你常常希望反復執(zhí)行同一段代碼。我們可以使用循環(huán)來完成這個功能,這樣就用不著重復地寫若干行相同的代碼。 JavaScript有兩種不同種類的循環(huán): for 將一段代碼循環(huán)執(zhí)行指定的次數(shù) while 當指定的條件為true時循環(huán)執(zhí)行代碼 for 循環(huán) 在腳本的運行次數(shù)已確定的情況下使用for循環(huán)。 語法:
The number is 0 The number is 1 The number is 2 The number is 3 The number is 4 The number is 5 The number is 6 The number is 7 The number is 8 The number is 9 The number is 10