logical AND (&&)
In JavaScript, the logical AND operator (&&) evaluates its operands from left to right and returns the first falsy operand it finds, or the last operand when every one is truthy. Once it reaches a falsy operand, it stops and never evaluates the operands to its right, a behavior called short-circuit evaluation.
The result is always one of the operands, unchanged, so && returns a boolean only when the operand it stops at is one. The falsy values that stop it include false, 0, -0, 0n, "", NaN, null, and undefined. With two Boolean operands, it returns true only when both sides are true.
JavaScript Logical AND Syntax
A logical AND expression joins two or more operands:
<left> && <right>
<operand1> && <operand2> [&& <operandN> ...]
A chain groups from the left and returns at its first falsy operand. Because && has higher precedence than the logical OR operator (||), a || b && c means a || (b && c).
JavaScript Logical AND Examples
Say a profile page reads a user’s city, but the user object may not be loaded yet. The expression user && user.city checks the object before it reads the property:
> const user = null;
undefined
> user && user.city
null
> const loadedUser = { name: "Ada", city: "London" };
undefined
> loadedUser && loadedUser.city
'London'
With user set to null, && returns null and never reads .city, so no error is thrown. With a loaded object, the left operand is truthy, and the expression evaluates to the right operand.
A notification badge should show a message only when there are unread items. Because && returns the falsy operand itself, a count of 0 comes back as the number 0:
> const unread = 0;
undefined
> unread && `${unread} new messages`
0
> unread > 0 && `${unread} new messages`
false
A template that renders the first result would display a stray 0. Comparing first turns the left operand into a Boolean, so the falsy result is false.
JavaScript Logical AND Gotchas
- A falsy left operand such as
0,"", orNaNcomes back as is, so code that expectsfalseor a string can receive a number instead. - The right operand doesn’t run when the left one is falsy, so a function call placed there is skipped without any warning.
- Mixing
&&with the nullish coalescing operator (??) without parentheses is aSyntaxError.
JavaScript Logical AND Use Cases
Related Resources
Course
JavaScript Conditionals for Pythonistas
Port a sailing club's race-day call from Python to JavaScript, and learn else if chains, the conditional operator, combined conditions, range checks, and switch.
Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.
By Leodanis Pozo Ramos • Updated Nov. 12, 2026