mysql for in 循环_for, for in, for of, map, forEach 循环的区别:

for, for in,  for of, map, forEach 循环的区别:

for  遍历数组:

1 //对象遍历数组

2 var arr =[3 {Monday: '星期一', Tuesday: '星期二', Wednesday: '星期三'}4 ]5 for (var i=0; i

6 console.log(i)7 console.log(arr[i])8 }

结果:

d4ad5e16376cc7f0ccb15136af3ca0c4.png

//数组

var arr = ["星期一","星期二","星期三"]

for (var j=0; j

console.log(j)

console.log(arr[j])

}

结果:

mysql for in 循环_for, for in, for of, map, forEach 循环的区别:_第1张图片

forEach:遍历数组,但不能使用break、continue和return语句:

//对象数组

var arr = [

{guangzhou: '广州', shanghai: '

你可能感兴趣的:(mysql,for,in,循环)