+ 1
how use this ||
3 Respuestas
+ 1
|| boolean operand OR
true || true = true
true || false = true
false || false = false
0
hi, || means the boolean operand OR
true OR false = true, true || false = true.
when used with one binary bit :
1 or 0 = 1 , 1 || 0 = 1
it is equivalent in electronics :
5V or 0V = 5V , 5V || 0V = 5V
it may be compared to an addition operand but it is not, because 1 OR 1 = 1 but 1 + 1 = 10 (binary)
so the + operand is called XOR where 1 XOR 1 = 0
true XOR true = false.
a OR b ie a || b is equivalent to if either of a or b are true or both are true then the result is true.
0
in jS
var a = true, b = false;
if(a || b) {code if condition is true}