For example, given:
const foo = {name: 'john', age: 12}
console.log(foo?.age);
Given the previous, we are safeguarding by using ?
in case foo
doesn't have the property age
but how can it be done in the next situation (if possible):
const foo = {name: 'john', house: {color: 'white', garage: true }}
console.log(foo['house']?['yard']
How to access a property, inside the property house
that might be undefined by using brackets?