Q:

Odd thing with javascript "undefined"

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..

A:

if(typeof input[i+1] === 'undefined') { ... }

A:

This:
if(typeof input[i+1] == undefined){

Should be:
if(input[i+1] === undefined){

(no need to use typeof)

A:

Undefined should be a string, "undefined", working fiddle: http://jsfiddle.net/asifrc/vRTsE/1/

