Short-circuits conditionals

Short-circuits conditionals method uses the && operator and It will call the second operand and return output if condition is true. In case if condition is false then it will return false as output.

Answers 1
  • Get double using arraw function with short-circuits conditional

    condition && do()
    //Code snippet
    const getDouble = (val) => { return val + val  }
    let online = true;
    let data = online && getDouble(20);

    Output :


    Short circuiting means that in JavaScript when we are evaluating an AND expression (&&), if the first operand is false, JavaScript will short-circuit and not even look at the second operand

  • Back to code snippet queries related javascript