What happens when I try to loop on an int like this:
var x = 0;
for (var k in x) {
// x[k]
}
Should I look for unexpected behavior or does it just not enter the loop?
(so far my experiments seem to show that it does not enter the loop… but it could do something I don’t see)
There are no methods defined in the vanilla JavaScript Number object prototype. Your code enters the loop (all objects in JS can be iterated) but there is nothing to iterate over in this case.
If you would do:
Your loop body would run once for the
fooproperty.