在while循环中重申

时间:2016-04-21 07:25:51

标签: javascript loops while-loop

Bar

我无法弄清楚为什么这个while循环不重复。使用的警报显示var i = 0; while (i < collection.length) { alert(i < collection.length); //true the first time... does not execute the second time if (collection[i].hasOwnProperty(Object.keys(source))) { alert(collection[i][Object.keys(source)]); //executes once } alert("out" + i); // out 0 i++; alert("out2 " + i); //i is incremented correctly to 1 alert(collection.length + " " + i); // 3 1 alert(i < collection.length); //returns true but does not iterate again. } 的增量,并且在第一次迭代结束时循环条件为真。这可能是一些小错误,但

0 个答案:

没有答案