Skip to content

Latest commit

 

History

History
19 lines (11 loc) · 732 Bytes

what_is_a_short_circuit_condition.md

File metadata and controls

19 lines (11 loc) · 732 Bytes

What is a Short-circuit condition?

A short-circuit condition occurs when the evaluation of a logical expression stops as soon as the result is determined. This is common with logical AND (&&) and OR (||) operators.

  • In an AND condition, if the first operand is falsy, the second operand is not evaluated.
  • In an OR condition, if the first operand is truthy, the second operand is not evaluated.

Example:

let a = false;
let b = true;
console.log(a && b);  // 'false', 'b' is not evaluated

**Tags**: [intermediate](./level/intermediate), [JavaScript](./theme/javascript), [Logical Operators](./theme/logical_operators)