Good points. Another one would be, in my opinion: if you are familiar with numeric count variables, like in a normal for-loop or even forEach(), you maybe get unexpected results with "for ... in":
var foo = ['a', 'b', 'c', 'd'];
foo.forEach(function (item, i) {
console.log(typeof i); // "number"
});
for (var i in foo) {
console.log(typeof i); // "string"
}
Good points. Another one would be, in my opinion: if you are familiar with numeric count variables, like in a normal for-loop or even forEach(), you maybe get unexpected results with "for ... in": var foo = ['a', 'b', 'c', 'd']; foo.forEach(function (item, i) { console.log(typeof i); // "number" }); for (var i in foo) { console.log(typeof i); // "string" }