|| falls through for every falsy value, so a default applied with it overrides a legitimate zero, an empty string and false.
const timeout = options.timeout || 30; // 0 becomes 30
const name = user.name || 'anonymous'; // '' becomes 'anonymous'
const enabled = flags.beta || true; // false becomes true
// 3.7
const timeout = options.timeout ?? 30; // 0 stays 0
const enabled = flags.beta ?? true; // false stays false
The third line is the one that produces a real incident: a feature flag explicitly set to false reads as enabled. Mixing ?? with && or || without parentheses is a syntax error rather than a precedence surprise, which is a deliberate and good decision by the committee. Combined with optional chaining it replaces most defensive code in a codebase reading API responses.