For-in loop on array
- for
- in
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.
"use strict";
var names = ["Foo", "Bar", "Qux"];
var v;
for (v in names) {
console.log(v);
}
// 0
// 1
// 2