true or false = true? | SoloLearn: Learn to code for FREE!

+2

true or false = true?

QUESTION var x = false || true; document.write(! (x !== true)); why false || true equal to true? Hope you can solve this for me! Thanks a lot!

11/20/2018 4:51:31 PM

Rex Hung

4 Answers

New Answer

+3

true and false is a boolean. For example : console.log(2 == 3) : false because the 2 numbers is different. console.log(2 == 2) : true because the 2 numbers is the same.

+1

The || operator means ‘or’, so a || b is ‘a or b’ and is true if either a is true or b is true. With false || true, the right hand side is clearly true, so the or statement evaluates as true.

+1

Logical "OR" ( || ) operator return true if one ore more of the expressions to be evaluated is true. You can read more about logical operators here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators.

0

Thanks