在迴圈裏有二個特定的敘述:中斷 (break)及繼續(continue)


線上範例

Break 敘述
以 break 敘述來中斷迴圈。

Continue 敘述
以 continue 敘述來中斷現行的迴圈,並繼續下一個值。


JavaScript break 及 continue 敘述

在迴圈裏有二個特殊的敘述:  break 及 continue.

Break

break 命令將中斷迴圈並繼續執行其它的迴圈。

範例






執行結果

The number is 0
The number is 1
The number is 2

Continue

continue 命令會中斷現行的迴圈,並繼續執行下一個值。

範例






執行結果

The number is 0
The number is 1
The number is 2
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


arrow
arrow
    全站熱搜

    easonyo 發表在 痞客邦 留言(0) 人氣()