I have the following javascript:
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 3 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 ?