Daily Software Tips & Tricks

Bite-sized knowledge to improve your coding skills daily.

The Power of Nullish Coalescing

April 23, 2026

Stop relying on the logical OR operator (||) for default values if zero or an empty string are valid inputs in your code. Using 'value || "default"' will overwrite 0 or false with your default, which often leads to subtle bugs. Instead, use the nullish coalescing operator (??). It specifically checks for null or undefined, letting those valid 'falsy' values pass through safely. It is a cleaner, more intentional way to handle data defaults in modern JavaScript or TypeScript.