JS学习笔记——遍历

遍历数组

//通过for of  /  for in 是下标
var arr=[3,4,5]
for (var x of arr){
    console.log(x)
}

遍历map

var map = new Map([["tom",100],["jack",90],["haha",80]]);
for (let x of map){
    console.log(x)
}

遍历set

var set = new Set([5,6,7]);
for(let x of set){
    console.log(x)
}

 

posted @ 2022-05-07 09:12  fight挺  阅读(23)  评论(0)    收藏  举报