vendredi 3 septembre 2021

Javascript If statement containing both AND ( && ) and OR ( || ) [duplicate]

I am puzzled why this statement evaluates to true:

(false && true || true) === true;

If the AND (&&) is a guard and the boolean proceeding it is false then it should have broken out of the if statement there, yet it doesn't and goes on to evaluate the OR (||) statement.

I had to do:

false && (true || true) === false;

to get the desired outcome. Anyone know why this is the case?

Aucun commentaire:

Enregistrer un commentaire