Daily Software Tips & Tricks

Bite-sized knowledge to improve your coding skills daily.

Simplify Deep Object Access with Optional Chaining

February 24, 2026

Dealing with deeply nested objects can lead to a frustrating series of null checks. Instead of writing long conditional chains to see if a property exists, use the optional chaining operator.

By writing user?.profile?.settings, the expression safely returns undefined if any part of the chain is nullish, preventing those annoying 'cannot read property of undefined' errors. It makes your logic much more readable and robust, especially when dealing with API responses that might have missing fields.