// 从一个数组对象中取key 和value组成一个新的对象
let arr = [
{lable: "checkItem1", value:2},
{lable: "checkItem5",value: 1}
]
// 方法1
let arr1 = arr.reduce((item,item1)=>{
return Object.assign({[item.lable]:item.value},{[item1.lable]:item1.value})
})
// 方法2
let arr3 = {}
arr.map(item=>{ arr3[item.lable] = item.value })
console.log(arr1,arr3)
/**
* { checkItem1: 2, checkItem5: 1 } { checkItem1: 2, checkItem5: 1 }
*/
记录一下,方便自己下次再用