Logical Operators
Logical operators work with boolean values or truthy/falsy values. && (AND) returns the first falsy operand or the last truthy operand. || (OR) returns the first truthy operand or the last falsy operand. ?? (nullish coalescing) returns the right operand only if the left operand is null or undefined.
let a = true;let b = false;console.log(a && b); // false (AND)console.log(a || b); // true (OR)console.log(!a); // false (NOT)
// Short-circuit evaluationconsole.log(0 && "hello"); // 0console.log(5 || "hello"); // 5