JavaScript-流程控制
if判断
var age = 3;
if(age>3){
alert("haha");
} else {
alert("wawa");
}
while循环避免程序死循环
while(age<100){
age = age +1;
console.log(age);
}
for循环
for (let i = 0; i < 100; i++) {
console.log(i)
}
for...in
//console.log(score) 在浏览器的控制台打印变量!
var age = [3,6,9];
//for(var index in object){}
for(var num in age){
if(age.hasOwnProperty(num)){
console.log("存在")
console.log(age[num])
}
}
forEach循环
var age = [3,6,9];
age.forEach(function (value){
console.log(value)
})