<分区>
Possible Duplicate:
When is a do-while appropriate?
有人介意告诉我这两个语句之间的区别是什么,什么时候应该用一个语句代替另一个语句?
var counterOne = -1;
do {
counterOne++;
document.write(counterOne);
} while(counterOne < 10);
或者:
var counterTwo = -1;
while(counterTwo < 10) {
counterTwo++;
document.write(counterTwo);
}
http://fiddle.jshell.net/Shaz/g6JS4/
此时此刻,如果不在 while
语句中指定它就可以完成,我不明白 do
语句的意义。