Logical AND (&&)

Returns the first falsy operand, or the last operand if all are truthy.

Since ES1 Spec ↗

Syntax

left && right

Returns

any — `left` if it is falsy, otherwise `right`.

Examples

console.log(true && "yes");
console.log(0 && "never");
Output
yes
0
const user = { name: "Ada" };
console.log(user && user.name);
Output
Ada
let called = false;
false && (called = true);
console.log(called);
Output
false

Notes

- Short-circuits: `right` is only evaluated if `left` is truthy. - Returns an operand value, not necessarily a boolean. - Often used for conditional execution and guarded property access.

Browser & runtime support

EnvironmentSince version
chrome 1.0
firefox 1.0
safari 1.0
edge 12
node 0.10

See also