I would suggest
if(typeof someObject != 'undefined') var foo = someObject.myProperty else return false;
You can also add a control to property using:
if(someObject.myProperty)
clearly inside the first if
Or ("maybe" less correct)
if(someObject) var foo = someObject.myProperty
the second example should work because undefined recognized as falsy value
steo
source share