if (typeof obj.foo !== 'undefined') { }
if (typeof foo !== 'undefined') { }
if (typeof obj.foo !== 'undefined') { // your code here }