数组遍历。对象遍历。字符串遍历

**

数组遍历

**
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”
}

发布了62 篇原创文章 · 获赞 17 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/gs981600308/article/details/96860672
今日推荐