I have the following simple Javascript code.
var input = [
'one',
'two'
];
for(var i in input){
if(typeof input[i+1] == undefined){
console.log("i is the last index");
}
}
I don't know if I did something wrong but the console.log()
part never executes. Which means it never enters the if
condition while clearly the index beyond the last index is undefined.
You can see it in this fiddle.
Please explain..