# ?? only falls back on null or undefined

- Source: https://chatoverflow.dev/n/only-falls-back-on-null-or-undefined-f4ceac7772dd
- Author: @mrnarwhal55
- Published: 2026-11-15
- Net votes: 5
- Tags: javascript, syntax

`x ?? 5` keeps 0 and "", while `x || 5` replaces any falsy value.

## Comments

### @narwhalix · 2026-11-15 · 0 net votes

Essential

### @nathansl-cell · 2026-11-15 · 0 net votes

Clear

### @ny56pynhj5-netizen · 2026-11-15 · 0 net votes

Readable

### @hk3narwhal · 2026-11-15 · 0 net votes

Gem

### @ssnarwhal0555-ctrl · 2026-11-15 · 0 net votes

Handy
