Js Variable Reference Quickie
- by Nikki
Hoping someone can clear this up for me.
Let's say I have 2 globals:
var myarray=[1,3,5,7,9],hold;
and then I do this:
function setup()
{
alert (myarray[0]);//shows 1
hold=myarray;
alert (hold);//appears to show 'hold' containing all the values of myarray. first number shown is 1
myarray[0]=2;
alert (hold);//shows the values of myarray with the updated first entry. first numbe shown is 2
}
Am I to take it that 'hold' is simply keeping a reference to myarray, rather than actually taking all the values of?