Edit in JSFiddle

var x;

if (typeof x === 'undefined') {
 console.log('x is undefined!');   
}