我有这个代码片段,我不知道为什么变量的值会改变。
while (increment > 0) {
for (i = increment; i < n; i++) {
var unsorted = list;
console.log(unsorted + " -> unsorted" + i);
var temp = list[i];
var j = i;
while (j >= increment && list[j - increment] > temp) {
list[j] = list[j - increment];
j -= increment;
}
list[j] = temp;
console.log(unsorted + " -> must not change" + i);
console.log(list + "-> must not be the same below");
}
}
当我再次记录变量unsorted
时,值已更改?为什么?