Let's say I have an object called John with many other nested objects inside and I am trying to access them following way
if (john.address.highstreet) {
var highstreet = john.address.highstreet
}
but if address property is null, then I will get an error
unable to get property 'highstreet' of undefined
and my function execution stops
Is there a way of accessing nested properties without making many nested if statements like it's shown below:
if (john.address) {
if (john.address.highstreet) {
var highstreet = john.address.highstreet
}
}