Two correct ways to use for/in
in JavaScript:
for (var i in a) {
if (!a.hasOwnProperty(i)) continue;
// loop body
}
for (var i in a) {
if (String(Math.floor(Math.abs(Number(i))))) !== i) continue; // ROFL !?
// loop body
}
The first way is not actually bullet-proof (e.g. when you have an array a
and somewhere in your code there's a['foo'] = 'bar'
, for example).