js数组转换为对象,并使用数组的 label 属性作为对象的键 qingfeng 2024-01-11 86 阅读1分钟 const array = [{label:"label",value:"value"},{label:"1",value:"2"}]; const reducedObject = array.reduce((obj, item) => { obj[item.label] = item.value; return obj; }, {}); console.log(reducedObject);