Favorites

JavaScript && Logical AND Operator

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
&&
JavaScript Logical OperatorThis operator is supported by all modern browsers.
Updated 28th November 2026

The logical AND operator (&&) returns the first falsy value, or the last value if all are truthy. In conditions it means both must be true.

Description

The logical AND operator && is true in a condition only when both operands are truthy. Strictly, it returns the first operand if that is falsy, otherwise the second, so it doesn't always return a boolean.

It short-circuits: if the left side is falsy, the right side isn't evaluated. That's why user && user.name doesn't throw when user is null, although optional chaining (user?.name) is now the clearer way to write it. && has higher precedence than ||.

Because it returns one of its operands rather than a boolean, && is used in frameworks such as React to render something only when a condition holds, {isLoggedIn && <Menu />}. Watch out for numbers: 0 && anything returns 0, which may be shown on screen. Converting the condition to a boolean, count > 0 && ..., avoids that.

Properties

Operator
&&
Category
Logical
Precedence
4 (1 is lowest, 18 is highest)
Associativity
left-to-right

Syntax

x && y

Example

const age = 25, hasTicket = true;
console.log(age >= 18 && hasTicket);
console.log('a' && 'b');
console.log(0 && 'never evaluated');
const user = null;
console.log(user && user.name);

Browser Support

The following information will show you the current browser support for the && operator. Hover over a browser icon to see the version that first introduced support for this operator.

This operator is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee