1 Reply Latest reply on Apr 8, 2017 2:25 AM by Jarda Bereza

    Bug: Logical && and || operator precedence is broken


      Not sure if this is the right place to report this.


      In Boolean algebra, the logical AND operator has higher order-of-operations precedence than logical OR. Therefore, the following two expressions should be equivalent:


      (true && true) || (true && false) // Result: true
      true && true || true && false // Result: false in JSX (should be true)


      In JSX, their results vary as indicated. The second expression is equivalent to this:


      ((true && true) || true) && false


      This does not follow logical order of operations. I confirmed that the two expressions both evaluate to true in other JavaScript engines.


      Workaround: Always use parens, but now I can't run my code through a minifier or obfuscator because it removes the extra parens to make the code smaller.