As demonstrated below, it appears that Array.forEach(myObject => callback) returns myObject as a reference to the exact object in my Array. Is there any built-in or graceful way to return an unreferenced copy of myObject in an Array.forEach without calling something like myObject = _.cloneDeep(myObject) on each iteration?
Thanks.
const trades = [
{ qty: 0 },
{ qty: 2 }
];
trades.forEach((trade, index) => {
trade.qty += 1;
trades[index].qty += 1;
console.log(trade);
});
console.log(trades);