Is there a way to incorporate new parameters into objects during a foreach loop in JavaScript?
const data = [big data];
data.forEach(async e => {
Object.assign(e, {newData: 'string'};
console.log(e); //new parameter added
})
console.log(data); //new parameter not added, why not?
During the forEach loop, I am trying to add a new parameter to each object. When I log the objects after using Object.assign, I can see that the new parameter has been successfully added. However, once the iteration is complete and I log my array of objects again, none of them seem to have the new parameter. Can anyone explain why this might be happening?