Daily Software Tips & Tricks

Bite-sized knowledge to improve your coding skills daily.

Stop the "Undefined" Crashes with Optional Chaining

February 11, 2026

We've all been there: checking if (user && user.profile && user.profile.name) to avoid a crash. Modern JavaScript and TypeScript give us the ?. operator, which makes this much cleaner. Using user?.profile?.name will simply return undefined if any part of the chain is nullish, keeping your code readable and your console free of those pesky "cannot read property of undefined" errors.