var
startx = 0,
starty = 0,
endx = 12,
endy = 100;
for(startx;startx <= endx; startx+=1){
for(starty; starty <= endy; starty+=1){
console.log(startx, endx, starty, endy);
}
}
預期輸出:在Chrome 39+雙for循環在JavaScript
0, 12, 0, 100
0, 12, 1, 100
0, 12, 2, 100
...
0, 12, 100, 100
0, 12, 0, 100
0, 12, 1, 100
0, 12, 2, 100
...
0, 12, 100, 100
1, 12, 0, 100
1, 12, 1, 100
...
12, 12, 100, 100
;EOO
輸出,這樣的問題是第一個for循環在startx的變量不重複。
你能告訴我它爲什麼不迭代嗎?
MS Edge的確如此。 實際的Firefox也是如此。 –