Skip to main content
The logical AND (&&) operator evaluates operands from left to right, returning the first falsy operand it encounters. If all operands evaluate to a truthy value, it returns the value of the last operand. Crucially, it performs short-circuit evaluation and returns the actual underlying value of the operand, not necessarily a boolean. Syntax
Evaluation Mechanics
  1. Left-to-Right Evaluation: The operator assesses expr1.
  2. Type Coercion: It implicitly coerces expr1 to a boolean to determine if it is truthy or falsy.
  3. Short-Circuiting: If expr1 is falsy, the operator immediately returns the exact value of expr1 and terminates evaluation. Subsequent expressions are completely ignored.
  4. Continuation: If expr1 is truthy, the operator proceeds to evaluate the next expression, repeating the process until it either finds a falsy value or reaches the final operand.
Falsy Values in JavaScript The && operator will short-circuit upon encountering any of the following strictly falsy values: false, 0, -0, 0n (BigInt zero), "" (empty string), null, undefined, and NaN. Behavioral Examples Returning the first falsy value:
Returning the last truthy value:
Operator Precedence The && operator has a higher precedence than the logical OR (||) operator, but a lower precedence than equality and relational operators (like ===, >, <).
Tired of Poor JavaScript Skills? Fix That With Deep Grasping!Learn More