当我调试此代码时,我看到父数组 (thisArray) 中的值正在更改,而代码未执行“thisArray =”代码。我已经包含了一个简单版本的代码,它复制了我遇到的问题。
我在这个数组中期待的结果
["Pass # 1","this is some data"]
["Pass # 2","this is some data"]
["Pass # 3","this is some data"]
我得到的结果
["Pass # 3","this is some data"]
["Pass # 3","this is some data"]
["Pass # 3","this is some data"]
我的代码
function debugThis(){
var thisArray = [];
var thisRow = [];
var pass = 0;
for (var i = 0; i < 3; i++) {
pass++;
thisRow[0] = 'Pass # ' + pass;
thisRow[1] = 'This is some data';
thisArray[i] = thisRow;
}
}