Daily Software Tips & Tricks

Bite-sized knowledge to improve your coding skills daily.

Say Goodbye to 'Cannot read property of undefined'

February 25, 2026

If you're still writing long chains of 'if (user && user.profile && user.profile.name)', it's time to embrace optional chaining. By using the '?.' operator, you can safely access deeply nested properties. If any part of the chain is null or undefined, it simply returns undefined instead of crashing your app. Pair it with the nullish coalescing operator '??' to provide a default value, and your code will look much cleaner and more robust.