I have this JS object:
baseFarm = {
name: "Farm",
tier: 1,
gridPos: 32,
}
and I want to push it to this array:
ownedLand = [];
This works perfectly, and if I console log this after the push I get:
Now, I want to push another another object to the same array, using that one as a base, however, I want the "gridPos" property to be different:
var newLand = baseFarm;
newLand.gridPos = parseInt( $('#purchaseLandPopupPlotNum').text() );
this.ownedLand.push(newLand);
However, after pushing this new object, the old one gets updated too:
What am I doing wrong?
Thanks in advance