Daily Software Tips & Tricks
Bite-sized knowledge to improve your coding skills daily.
Stop Fearing the Undefined
April 2, 2026
If you are tired of writing long chains of 'if' statements to avoid errors when accessing nested properties in JavaScript or TypeScript, start leaning on optional chaining (?.). It short-circuits the evaluation if a reference is nullish, returning undefined instead of throwing an error. Pair it with the nullish coalescing operator (??) to provide a default value, and your data-fetching logic will look significantly cleaner.