Zero is a valid score even though it is falsy. A nullish default expresses absence without erasing an actual measurement.
Worked example
type Profile = {
name: string;
contact?: { email?: string };
score: number | null;
};
const profiles: Profile[] = [
{ name: "Ada", score: 0 },
{ name: "Ben", contact: { email: "b@example.org" }, score: null },
];
console.log(profiles.map((p) => p.score ?? 10));Result
[ 0, 10 ]Implementation notes
A default should not convert an unknown score into a measured score accidentally. Preserve absence when the UI distinguishes missing data from a true zero.
Try it yourself
Compare a missing score, zero and a positive score.
Open the TypeScript example →Editorial date September 15, 2025 · Published December 6, 2026