【发布时间】:2014-05-18 08:42:36
【问题描述】:
this.lastLocations[0] = this.locations[0];
this.locations[0].x++;
执行此代码时,它会同时增加位置[0].x 和 lastLocations[0].x。我希望它只是改变位置[0].x。这是因为 javascript 分配的是引用而不是值吗?还是我的代码中的其他地方有问题?
【问题讨论】:
-
oo 明白了。仍在学习堆栈溢出机制和礼仪。
标签: javascript variable-assignment pass-by-reference