← DevOps Foundations
6 / 25
Lesson 6 — Config defaults
|| versus ??
Two ways to give a default:
a || busesbifais falsy — that includes0,""andfalse;a ?? busesbonly ifaisnullorundefined.
So with retries: 0, config.retries || 3 gives 3 (wrong — the user asked for 0), while config.retries ?? 3 gives 0.
Why it matters: a config value of 0 or false is a real choice; ?? respects it.
Want it another way?
Task
Change both lines to use ?? so retries stays 0 and debug stays false.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
Test your knowledge
A quick 3-question quiz on this lesson — instant feedback.