JavaScript while ??
while ??? JavaScript?? ?? ??? ?????. ??? ??? ????.
while(expr){
?
}
? ??? expr ???? TRUE? ? ?? ?? ??? ?? ?????. expr? FALSE? ? ??? ???? ??? ???? ??? ?????.
?? ???? while ??? ???? 1~10? ?????.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <script type="text/javascript"> var i = 1; while (i <= 10) { document.write(i + "<br />"); i++; } </script> </head> <body> </body> </html>
?? ??:
1
2
3
4
5
6
7
8
9
10
do while ??
do while ??? while ??? ?? ?????. ??? ???? do while? ? ?? ????? ????. ?? while? ???? ???? ??? ???? ?? ?? ? ????. ?? ??.
do while ?? ??:
do {
?
}while (expr)
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <script type="text/javascript"> var i = 1; do { document.write(i + "<br />"); i++; } while (i <= 10); </script> </head> <body> </body> </html>
for? while ??
for ??? ?? ?? ?? ???? ??? ???? ? ????. while ??? for ??? ?? ?????.
for ?? ??
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> <script> cars=["BMW","Volvo","Saab","Ford"]; var i=0; for (;cars[i];){ document.write(cars[i] + "<br>"); i++; } </script> </body> </html>
while ?? ??
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> <script> cars=["BMW","Volvo","Saab","Ford"]; var i=0; while (cars[i]){ document.write(cars[i] + "<br>"); i++; } </script> </body> </html>