
A retry control allows a person to disable retries by explicitly entering zero. A fallback based on ordinary truthiness accidentally re-enables the default. Null and undefined pick the default. Zero survives because it is a configured value with a distinct operational meaning.
A runnable JavaScript fixture
The example keeps the input to Nullish_coalescing outside the function, so it is possible to run the same transformation in a test. The comparison uses concrete data rather than the rendered component. If the application accepts a value from JSON, run the fixture after parsing that JSON to preserve the relevant types.
function evaluate(value) {
return value.limit ?? 3;
}
const samples = [{"limit": 0}, {"limit": null}, {}];
for (const sample of samples) console.log(evaluate(sample));The result for three concrete cases
| Input | Return value |
|---|---|
| {"limit": 0} | 0 |
| {"limit": null} | 3 |
| {} | 3 |
For {"limit": 0}, the observed output is 0. With {"limit": null}, it becomes 3. If a second implementation produces a different answer, begin with these small inputs. They allow a reviewer to trace the expression without reconstructing the entire application or replaying a production workload.
The value for {} is 3. Record the unit or indexing convention next to that expectation. A second implementation can return the same type and still disagree about where a boundary falls or which observations enter the calculation.
An acceptance check for the real feature
A negative or fractional limit still passes this expression. Range validation belongs alongside the defaulting rule.
Run one case twice through the real feature and look at both the displayed value and its stored representation. A component may coerce a result to text even when the implementation returns a numeric measurement. Keep a failing sample small enough that it can travel with a bug report, including the browser or Node version that produced it.
One more fixture before integrating
Use persisted configuration from before the retry setting existed as a fixture. An omitted field in an old record should choose the documented default, while a newer explicit zero should keep retries disabled after the same update.
The same JavaScript function was also run with {} / {"limit": 0, "extra": 1}. These additional inputs change the boundary without changing the implementation. An exception name in the table records where the operation rejects an input; a returned empty or zero value records a successful call. Choose deliberately which of those outcomes the surrounding feature should expose.
| Additional fixture | Result or exception |
|---|---|
| {} | 3 |
| {"limit": 0, "extra": 1} | 0 |
JavaScript operator reference · MDN JavaScript language guide
Sources and further reading
Cover photograph: Raspberry PI hdmi-vga connector by Антон Пищулин. CC BY-SA 4.0. Cropped and typeset for this cover. The photograph illustrates the topic. This image adaptation uses the same share-alike license.
