Assuming an object like this
var a = {
b: {
c: [
{
e: 'hello'
},
{
f: 'bye'
}
]
}
};
I want to check if e is valid.
Currently I am using multiple if conditions like
if (typeof a !== 'undefined' && typeof a.b !== 'undefined' && typeof a.b.c !== 'undefined' && typeof a.b.c[0] !== 'undefined') {
console.log('value of e ' + a.b.c[0].e);
}
Is there a cleaner way to achieve the same result?
Thanks