We don't have to use the C-style for-loop on arrays. We can use the simpler, for-in construct. It will iterate over the index of the array.

examples/intro/for_in_loop_on_array.js
"use strict";

var names = ["Foo", "Bar", "Qux"];
var v;
for (v in names) {
    console.log(v);
}
// 0
// 1
// 2