Consider the following code:
var arr = [111, 222, 333];
for(var i in arr) {
if(i === 1) {
}
}
It will not succeed because typeof i === 'string'.
Is there any way around this? I could explicitly convert ito integer, but it seems to defeat the target using a simpler for ininstead of the usual for-loop.
Edit:
I know the use ==for comparison, but this is not an option.
source
share