1
希望有人能爲我解決這個問題。假設我有兩個全局變量: var myarray = [1,3,5,7,9],hold;Js Variable Reference Quickie
,然後我這樣做:
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
}
我憑什麼認爲「持有」僅僅是保持一個參考MYARRAY,而不是實際採取的所有值?