+ 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!
4 odpowiedzi
+ 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