I am just trying to understand at what level of an object to use optional chaining. If I have the given object
foo: {
other: {
name: "Bill"
}
}
rather than do this:
if (foo && foo.other && foo.other.name) { ... }
I want to use optional chaining but I always finding myself just adding ?. at every level.
would the proper way be to add it to every level like this:
if (foo?.other?.name) {
}
or can you leave the last one out since that will result in false if it's not there:
if (foo?.other.name) {
}