What does this expression mean in JS?
Value |= this.value
A single vertical bar means bitwise or. Show activity on this post. Bitwise inclusive or: The bitwise-inclusive-OR operator compares each bit of its first operand to the corresponding bit of its second operand.
The vertical bar is also used in programming languages as a logical or bitwise operator that represents OR logic. The vertical bar makes it possible to specify alternative values within an expression. For this reason, it is sometimes referred to as an alternation operator.
It means logical sum . var time = $(el).
The double pipe operator (||) is the logical OR operator . In most languages it works the following way: If the first value is false, it checks the second value. If it's true, it returns true and if it's false, it returns false. If the first value is true, it always returns true, no matter what the second value is.
This will perform a bitwise OR between the bits in this.value
and the bits already stored in Value
, then store the result back into Value
.
var Value = 42; // 00101010 Value |= 96; // 01100000 window.alert(Value); // 01101010 -> 106
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With