ES6 函数解构 中的遍历方式:循环

    

let arr = [1,2,3,4,5,6]


//遍历方式一
for(let item of arr){
    console.log(item)
}


//遍历方式二
arr.map(function(item){
    console.log(item)
})



//箭头函数遍历

[[1,2],[3,4]].map(([a,b] => return a+b))
// 答案:3,7

你可能感兴趣的:(es6)