Daily Software Tips & Tricks
Bite-sized knowledge to improve your coding skills daily.
Stop Fearing the 'Undefined' Crash
May 8, 2026
We've all seen the dreaded "cannot read property of undefined" error. Instead of writing long chains of if (user && user.profile && user.profile.name), embrace optional chaining with user?.profile?.name. It’s cleaner, shorter, and safely returns undefined instead of crashing your app. Pair it with the nullish coalescing operator (??) to provide a default value effortlessly.