如何在 JavaScript 中在数组内传播对象

How to spread Objects inside Array in JavaScript

我有这个数组

[
  {FirstName: 'Emeka'},
  {MiddleName: 'Praise'},
  {LastName: 'Orji'},
  {Date: 'Today'},
  {Month: 'July'},
  {Year: '2022'},
  {Gender: 'Female'},
  {MaritalStatus: 'married'},
  {State: 'Lagos'},
  {Origin: 'Ape'},
]

我想把它变成一个对象

{
  FirstName: 'Emeka',
  MiddleName: 'Praise',
  LastName: 'Orji',
  Date: 'Today',
  Month: 'July',
  Year: '2022',
  Gender: 'Female',
  MaritalStatus: 'married',
  State: 'Lagos',
  Origin: 'Ape',
}

我关注这个很久了 请问我该怎么做?

const src = [
  {FirstName: 'Emeka'},
  {MiddleName: 'Praise'},
  {LastName: 'Orji'},
  {Date: 'Today'},
  {Month: 'July'},
  {Year: '2022'},
  {Gender: 'Female'},
  {MaritalStatus: 'married'},
  {State: 'Lagos'},
  {Origin: 'Ape'},
];

const result = src.reduce((collector, item) => {
  Object.assign(collector, item);
  return collector;
}, {});

console.log(result);

let obj = {}
for(let i =0; i< arr.length; i++){
  let o = Object.keys(arr[i])
  obj[o[0]] = arr[i][o[0]]
}