JavaScript/while

来自康健生活

引言

结束

break

let i = 0;
while (i < 5) {
  console.log('the i is ', i);
  if(i===2) break;
  i++;
}
the i is  0
the i is  1
the i is  2

死循环

while

while(表达式) {
  循环体
};

do while

do {
 // TODO
}
while(表达式);