do{}while() 循环至少会循环一次:
语法如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>DEMO - Lik</title> </head> <body> <script> var a = 0; do{ a++; console.log(a); }while(a<5); </script> </body> </html>
控制台会输出:
do{}while() 循环至少会循环一次:
语法如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>DEMO - Lik</title> </head> <body> <script> var a = 0; do{ a++; console.log(a); }while(a<5); </script> </body> </html>
控制台会输出: