Something weird is happening with Javascript as I try to copy an object, and set one of the copied variables to 1. When I console.log the variable directly, it's set. When I console.log the object, that value is undefined.
const addedItem: ProductToPlan = (JSON.parse(JSON.stringify(item)));
addedItem.amountToAdd = 1;
console.log(addedItem.amountToAdd);
console.log(addedItem);
The object ProductToPlan does have the variable 'amountToAdd' defined in its class definition (as a number).
Screenshot of the console:
As you can see, te first line echoes '1' as it should, but then when I echo the object, it's undefined.
It's quite possible I'm doing something wrong, I just don't know what it is or what to search for.
What am I missing?