function setup() {
let currentState = [];
let i;
let j;
//code that populates the array
currentState[0] = [undefined,undefined,undefined,undefined,undefined,undefined,2,4];
currentState[1] = [undefined,undefined,0,1,3,3,5,5];
currentState[2] = [undefined,undefined,0,1,2,2,4,4];
currentState[3] = [undefined,0,1,1,2,3,4,5];
i = 0;
j = 1;
//check the state of the array and iterators, for bugtesting
console.log("i = " + i);
console.log("j = " + j);
console.table(currentState);
console.log();
//code that randomize each row, the result:
currentState[0] = [undefined,4,undefined,undefined,undefined,undefined,undefined,2];
currentState[1] = [3,3,5,5,undefined,undefined,0,1];
currentState[2] = [2,2,4,4,undefined,undefined,0,1];
currentState[3] = [1,2,3,4,5,undefined,0,1];
i = 2;
j = 2;
//check the state of the array and iterators, for bugtesting
console.log("i = " + i);
console.log("j = " + j);
console.table(currentState);
}
我在控制台中写console.table(currentState);
的两个地方都得到了相同的状态。我想看看数组在随机化之前和之后的状态。现在两个console.table()调用都显示了随机化之后的数组。这让bug测试变得很混乱。
我做错了吗?还是有别的办法?
1条答案
按热度按时间hgb9j2n61#
好的,我找到了一个解决方案。它实际上在评论中,我错过了它,因为我忙碌了试图创建一个最小可复制的例子。
Is Chrome’s JavaScript console lazy about evaluating objects?
解决办法是这样写:第一个月
你每天都会学到新的东西!非常感谢每一个做出贡献的人!