关于html:我很困惑使用javascript数组

i m confused working with javascript arrays

本问题已经有最佳答案,请猛点这里访问。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var x = [1, 2, 3, 4, 5, 6];

function change1(y) {
  y[0] = 7;
  y[1] = 8;
  y[2] = 9;
  y[3] = 10;
  y[4] = 11;
  y[5] = 12;
}
change1(x);
console.log(x);

var z = [1, 2, 3, 4, 5, 6];

function change2(y) {
  y = [7, 8, 9, 10, 11, 12];
}
change2(z);
console.log(z);

输出:

1
7,8,9,10,11,12 1,2,3,4,5,6

在我的理解unable以上代码为什么change1()祭坛的功能可以通过数组不能当这change2()功能。

行啦,以及为什么打破冰不工作?

谢谢


(P)EDOCX1 0 is modifying an existing object.That change is visible to anything that holds a reference to that object.(p)(P)EDOCX1 an entirely new value to the local EDOCX1 universal 2.Variable and discards the previously assigned object reference.这一变化是看不见的外部功能,因为没有它,你已经获得了(p)