I have an array of objects :
parsedObjs = [
{
BusinessName: 'Exmaple1...',
Employeeid: 1234664,
Rank: 3,
PublishDate: 2019-08-09T21:00:00.000Z
},
{
BusinessName: 'Exmaple2....',
Employeeid: 1234666,
Rank: 4,
PublishDate: 2019-08-09T21:00:00.000Z
},
... more
]
and a property that I want to add to each object :
const addThis = {supplier: req.supplier.id}
I've tried to use the spread operator :
const spreadedItems = [
...parsedObjs,
addThis
];
But it doesn't do the trick.
How can we add a property to an array of objects ?