I have the following JavaScript code:
oCoord = {x: null, y: null};
var aStack = [];
oCoord.x = 726;
oCoord.y = 52;
aStack.push(oCoord);
oCoord.x = 76;
oCoord.y = 532;
aStack.push(oCoord);
oCoord.x = 716;
oCoord.y = 529;
aStack.push(oCoord);
Now this creates the following structure (an array of three objects).
Array[Object, Object, Object];
However, when I try and access the properties of each object they are all coming out the same. Why is this?
alert(aStack[0].x); // Outputs 716
alert(aStack[1].x); // Outputs 716
alert(aStack[2].x); // Outputs 716
What am I doing wrong?