You can use reduce to create a new version of the object.
The reduce() method executes a reducer function (that you provide) on each member of the array resulting in a single output value.
With reduce, we first pass in a function that executes on each item and returns a new output value, then we pass a second parameter defining the initial structure of the single output value.
let data = [
{firstName: 'John', lastName: 'Doe'},
{firstName: 'Mike', lastName: 'Smith'}
]
// o = the current output value
// i = the current item in the array
let result = data.reduce((o, i) => {
// Add the first/last names to the corresponding array
o.firstName.push(i.firstName)
o.lastName.push(i.lastName)
// Return the new current output value
return o
}, { firstName: [], lastName: [] }) // Sets the initial output value
console.log(result)