Ok, I have this code:
var room = [ { time: 0, people: 0 } ];
and then:
time = 5;
for( var i in room ) {
if( room[i].time < time ){
spliceIndex = i + 1;
}
}
console.log(spliceIndex);
And the console reads: 01
- Which means the 1 is concatenated which further means that i
is a string, and not an integer as expected. Casting the index to integer fixed the problems, but I was banging my head for hours.... Can anyone explain why is this happening? I get this on Firefox 3.5 and Safari 4.