- ISSUE: value assignment to pushed row is affecting both rows.
- DESIRED OUTCOME: only assign new value to indicated row.
In google apps script, in the example below I push the last row into an array, so it's last two rows are duplicated. Then I want to change one value in the new row. Unfortunately, those two rows seem bound now, so any change to one affects both. Why and how do 'unbind' them?
function mre1 () {
arr1 = [[1,2,3],[6,7,8],[3,4,5]]
arr1.push(arr1[arr1.length-1]);
arr1[arr1.length-1][1]=100;
Logger.log(arr1);
// ACTUAL [[1.0, 2.0, 3.0], [6.0, 7.0, 8.0], [3.0, 100.0, 5.0], [3.0, 100.0, 5.0]]
// DESIRED [[1.0, 2.0, 3.0], [6.0, 7.0, 8.0], [3.0, 4.0, 5.0], [3.0, 100.0, 5.0]]
}