P粉9252399212023-08-14 14:46:08
Cannot do this. map
Outputs an array (where each value is the result of passing the value at the matching index in the original array to the function). If you expand the array into an object, you will get the index (number) as the property name and the value as the value.
If you want to start with an array and end with an object, then map
is the wrong tool. Please use reduce
instead.
Code similar to the following:
const combined = second.reduce( (prev, curr) => { return { ...prev, [curr]: new Date() }; }, first );