Search code examples
javascriptassignment-operatorboolean-expressionboolean-operations

why assignment operators return non boolean value


I tested result this javascript expressions in chrome browser console (output result is bold):
a = false
false
b = false
false
a||b
false
a|=b
0
why in the last expression (a|=b) does not return a boolean?

UPDATE: Can I do this? a=!!(a|=b)


Solution

  • Bitwise operators treat their operands as a set of 32 bits (zeros and ones) and return standard JavaScript numerical values.

    Taken from mdn