1,while

    1. while(表达式){
    2. 代码块
    3. }
    4. 表达式为true, 会一直执行while中的代码块
    1. var a = 0;
    2. while (a <= 3) {
    3. //只要a<=10为true就一直循环
    4. alert(a);
    5. a++;
    6. }

    2 do—-while(了解)
    tips:即便不满足条件,循环体也会先执行一遍

    1. do{
    2. 循环体
    3. }while(循环条件)
    1. var a = 0;
    2. do {
    3. console.log(a)
    4. a++;
    5. } while (a <= 3)