📌  相关文章
📜  将字符串数组转换为对象数组javascript代码示例

📅  最后修改于: 2022-03-11 15:03:54.643000             🧑  作者: Mango

代码示例3
[
  { id: 10, color: "red" },
  { id: 20, color: "blue" },
  { id: 30, color: "green" }
].reduce((acc, cur) => ({ ...acc, [cur.color]: cur.id }), {})

//output: 
{red: 10, blue: 20, green: 30}