Once you start using optional chaining and really think about it, you should see that

if (user && user.profile && user.profile.avatar) {
console.log(user.profile.avatar);
}

is actually more reliable than

console.log(user?.profile?.avatar);

because the first approach has the "if" that allows for "else" - in a logical sense.

The compactness of optional chaining does not make it more reliable.

allthingssmitty.com/2025/06/02

0

If you have a fediverse account, you can quote this note from your own instance. Search https://floss.social/users/andrija/statuses/114655834242728375 on your instance and quote it. (Note that quoting is not supported in Mastodon.)