Conditional Operand Selectors

Video

JavaScript Notes

JavaScript
    // conditional operand selectors
    let log = console.log;

    log(true && true);      // true
    log(false && true);     // false
    log(true || false);     // true
    log(false || true);     // true
    
    log(0 && true);     //0 - && looks at the first and if it is truthy renders the second, otherwise it renders the first
    log(1 && true);     //true
    log(0 || false);    // false - if falsey, renders the last in the sequence
    log(1 || true);     // 1 - if truthy, renders the first in the sequence
    
    log(0 && "text");    // 0
    log(1 && "text");    // text
    log(0 || "text");    // text
    log(1 || "text");    // 1
    
    log(false && "text"); //false
    log(true && "text"); //text
    log(false || "text"); // text
    log(true || "text"); // true
    
    //react will render the following primitives
    // 0, 1, Null, Strings, NaN
    // react will not render
    // booleans, undefined, null, empty strings, empty arrays | objects