数组遍历
for
for(var i=0;i<arr.length;i++){
......
}
forEach
arr.forEach((res,index)=>{
......
})
map遍历,map遍历支持使用return语句,支持return返回值
arr.map((res,index)=>{
......
})
for ... of
for( let i of arr){
....
}
对象遍历
for ...in
for( let i in arr){
....
}
字符串遍历
for...of
for( let i of arrString){
console.log(i);// arrString="abcd"; ===>"a","b","c","d"
}