if判断
'use strict'; let age = 3; if (age<3){//第一个判断 alert("kuwa"); }else if(age=5){//第二个判断 alert("5"); } else{//否则 alert("hhh"); }
while循环,避免程序死循环
while(age<100){ age = age + 1; console.log(age); } do{ age = age + 1; console.log(age); }while(age<100);
for循环
for (let i = 0; i < 100; i++) { console.log(age); }
forEach循环
let arr = [16,46,14,43,78,9,40,11,4]; //函数 arr.forEach(function (value){ console.log(value); });
for...in
/* *for(Type str:el){} * */ //for(var index in object) for(let num in arr){ if (arr.hasOwnProperty(num)){ console.log("存在"); console.log(arr[num]); } }