That’s right, the for (x in y)
used by JavaScript is dumb. And what is more,
they can’t change it without royally screwing up people who have worked around
it.
When used with arrays, the x
will represent the index of the array, not the
value (as is common in most languages).
Sure, I agree that this is a useful feature to have, but why must it do it by default.
So to recap: To iterate through an array in Javascript using this control structure you must do it as shown below:
1 2 3 |
|
Stupid.