Logical AND (&&)
Logical AND: returns the first falsy value, or the last one.
Available since: ES1
Syntax
a && bExamples
In conditions — both are true:
const age = 25;
const hasTicket = true;
console.log(age >= 18 && hasTicket);Output:
trueRunning an action only if a condition holds:
const user = { isAdmin: true };
user.isAdmin && console.log('Show admin panel');
console.log(0 && 'never');Output:
Show admin panel
0Notes
If the left side is falsy the right side is not evaluated. && binds tighter than ||: a || b && c means a || (b && c).
See also
- Logical OR (||) — Logical OR: returns the first truthy value.
- Optional chaining (?.) — Safe property access: returns undefined instead of an error if the object is missing.
In the tutorial
- Logical operators — JavaScript logical operators — AND, OR, NOT, their precedence, default values with || and the ?? operator.