&& || ! ?? Logical operators
Last updated: 2026-09-09
&& || ! ?? Logical operators
Logical operators combine conditions. && short-circuits, || short-circuits, ! negates, ?? coalesces.
| Category | Operators |
|---|---|
| ES version | ES1 |
📝 Syntax
a && b; a || b; !a; a ?? b;
Returns:A boolean or one of the operands.
Mutates the original:No (returns a new value)
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
anon
unknown
has name
⚠️ Warning || replaces 0 and '' too — use ?? when only null/undefined should trigger.
💡 Tip ?? (ES2020) solves the over-replacement problem of ||.
🌐 Browser support
| Browser | |||||
|---|---|---|---|---|---|
| && || ! ?? | ✓ v1 | ✓ v12 | ✓ v1 | ✓ v1 | ✓ v1 |
| Supported by all modern browsers | |||||
🏷️ Related Operators
💡 Related Cases
More case studies coming soon — check back later.
📚 Related Tutorials
❓ FAQ
Q|| vs ???
A|| triggers for all falsy; ?? only for null/undefined.
QWhat does && short-circuit mean?
AIf the first is falsy, the second is not evaluated.
Q! vs !!?
A! negates; !! converts to boolean.