Daily Software Tips & Tricks

Bite-sized knowledge to improve your coding skills daily.

Cleaning Up Deep Object Access

February 23, 2026

We've all been through the 'cannot read property of undefined' nightmare when digging through deeply nested JSON objects. Instead of writing long chains of checks like `if (user && user.profile && user.profile.address)`, start using the optional chaining operator (`?.`).

By writing `user?.profile?.address`, JavaScript will automatically stop and return `undefined` if any part of the chain is nullish, preventing your app from crashing. It makes your code significantly more readable and less prone to those annoying runtime errors that always seem to pop up at the worst possible time.