In the below code, I am passing an array of objects in the map function. The Value of category
gets assigned to categoryName
and is returned as categoryName
. My problem is understanding the assignment operation. Doesn't the assignment to object properties happen this way key:value
? Instead, I see that the value of category
is assigned to this new Variable in this fashion value:key
const companies= [
{name: "Company One", category: "Finance"},
{name: "Company Two", category: "Retail"}
];
const companyu = companies.map(
({ name, category: categoryName }) => ({ name, categoryName }))