Daily Software Tips & Tricks

Bite-sized knowledge to improve your coding skills daily.

Simplify Your Null Checks

February 24, 2026

Tired of writing nested if-statements just to access a property deep inside an object? JavaScript's optional chaining operator (?.) is a total lifesaver for keeping your code readable. Instead of checking if 'user', 'user.profile', and 'user.profile.settings' all exist individually, you can simply write 'user?.profile?.settings?.theme'.

If any part of that chain is null or undefined, the expression short-circuits and returns undefined instead of throwing a 'TypeError: Cannot read property of undefined'. It’s a small syntax change that removes a massive amount of boilerplate logic from your components.