js中的新循环怎么写
let list = [1,2,3,4,5]
1.forEach(item=>{
return item+1
})//list修改成[2,3,4,5,6]
2. for(const index in list){
console.log(index)//[0,1,2,3,4,]
}
3.for(const value of list ){
console.log(value)//[2,3,4,5,6]
}
4.const newList = list.map((item,index){
return item+1
})
console.log(list)//[2,3,4,5,6]
console.log(newList)//[3,4,5,6,7]
赞0
踩0