Edit in JSFiddle

var x;

if (x === undefined) {
    console.log('x is undefined!');
}
// or
if (x == undefined) {
    console.log('x is undefined or null!');
}