In Javascript, I'm having trouble understanding why these two sets of code provide different results:
for (var i = 0, a = []; i++ < 9;) {a.push(i);}
After running this code, the variable a
is the following: [1, 2, 3, 4, 5, 6, 7, 8, 9]
.
However, this code returns something else:
for (var i = 0, a = []; i < 9; i++) {a.push(i);}
Instead, the variable a
is the following after running this code: [0, 1, 2, 3, 4, 5, 6, 7, 8]
So, the major question: Why is this the case?
Thanks for any answers that explain this difference.