The following code checks if sum
has operand
, the code is very straightforward, but I'm confused by the condition (sum & operand) === operand
.
I've read the Bitwise AND (&) doc, confused me even more, can someone explain it in simple terms?
const has = (sum, operand) => (sum & operand) === operand
console.log(has(7, 4))