Javascript Variable Declaration Issue
<pre><code>var Stars = new Array(1,2,3,4,5,6,7,8,9,10);
var StarsX = new Array(451,455,460,470,490,100,160,220,280,300);
var StarsY = new Array(451,455,460,470,490,480,390,330,200,120);
var Starsm = Stars
var StarsmX = StarsX
var StarsmY = StarsY

//just shows the output of the variables in a text field
function contpost(){Tfield.innerHTML=Stars + "&lt;br/&gt;" + StarsX + "&lt;br/&gt;" + StarsY + "&lt;br/&gt;" + Starsm + "&lt;br/&gt;" + StarsmX + "&lt;br/&gt;" + StarsmY;}

//cycles through the "for" loop and posts the variables
function newpost(){
for (var i=0;i&lt;Stars.length;i++){
    StarsmX[i] = StarsX[i] + 10;
    StarsmY[i] = StarsY[i] + 10;
    }
contpost()
}


var Tfield= (This is the text field)
var canv_one= (This is a canvas in my document)
canv_one.addEventListener('click', newpost);
</code></pre>

<p>If I run this code (Firefox 9), the if/then loop adds 10 to both the "mX" variable and the "X" variable.</p>

<p>I now know approximately how it does it. It's simply because I set them equal early on. When I substitute this in the declarations, it works properly:</p>

<pre><code>var Starsm = new Array()
var StarsmX = new Array()
var StarsmY = new Array()
</code></pre>

<p>What I don't understand is why javascript is doing this. It seems logical to me that if you set them equal once, during the global declaration, they will not re-equate later on (and do it backward, at that. I never set StarsX equal to StarsmX.)</p>

<p>I'm pretty sure this means I'm not understanding some kind of basic functionality of Javascript, and that worries me.</p>

<p>Can anybody help?</p>
