Choose the operator from the field’s meaning. For Millbrook’s phone field, an empty string means no number, so || tries the next source. For a deposit, zero is a real waiver, so ?? keeps it and defaults only for null or undefined.
The final phone and deposit lines use the current booking r and its saved regular-hirer setting regular, read from REGULARS.get(r.name). With DEFAULT_DEPOSIT set to 50, the choir gets its saved phone and a zero deposit.
const phone = (
r.phone
|| regular?.phone
|| "no phone given"
);
const deposit = regular?.deposit ?? DEFAULT_DEPOSIT;
?? preserves 0, "", false, and NaN; || uses the fallback for those values. Both use the fallback for null and undefined. Neither operator validates input. Python’s dictionary default covers a missing key; ?? also covers an explicit null.
Keep one operator throughout a chain, or group the part that goes first with parentheses, as in (r.phone || regular?.phone) ?? "no phone given".
Next up: Fill In the Setup Sheet. Prepare the caretaker’s equipment and entrance for each booking so every setup line matches the Python script.