Good morning. I'm trying to decipher what this function is doing as I'm new to JS and breaking it down line by line. I also tried putting the function into Babel to see if it would be more explicit.
const t = objArray =>
Object.assign(
{},
...objArray.map(
({ v, k }) => ({ [k]: v
}))
);
This is what I believe is occurring:
const t = objArray =>
Object.assign(
{},
- an array object is being cloned with all properties of objArray
...objArray.map(
({ v, k }) => ({ [k]: v
}))
);
- This is where I get a little confused. Is objArray being mapped to a new array object where each array element holds a key and val?
Any help and tips to decipher these complex functions are greatly appreciated. Thank you