while expression
statements to be executed
console.log "Starting Loop " count = 0 while count < 10 console.log "Current Count : " + count count++; console.log "Set the variable to different value and then try"
c:\> coffee-c while_loop_example.coffee
// Generated by CoffeeScript 1.10.0 (function() { var count; console.log("Starting Loop "); count = 0; while (count < 10) { console.log("Current Count : " + count); count++; } console.log("Set the variable to different value and then try"); }).call(this);
c:\> coffee while_loop_example.coffee
Starting Loop
Current Count : 0
Current Count : 1
Current Count : 2
Current Count : 3
Current Count : 4
Current Count : 5
Current Count : 6
Current Count : 7
Current Count : 8
Current Count : 9
Set the variable to different value and then try
循环类型和描述 |
while 的until 变体
while 循环的
until 变体包含一个布尔表达式和代码块。只要给定的布尔表达式为假,这个循环的代码块就会被执行。
|
while 的循环变体
loop 变体等效于
while 循环具有真值
(同时为真)。此循环中的语句将重复执行,直到我们使用
Break 语句退出循环。
|