--- title: Bitwise OR assignment (|=) slug: Web/JavaScript/Reference/Operators/Bitwise_OR_assignment translation_of: Web/JavaScript/Reference/Operators/Bitwise_OR_assignment ---
The bitwise OR assignment operator (|=
) uses the binary representation of both operands, does a bitwise OR operation on them and assigns the result to the variable.
Operator: x |= y Meaning: x = x | y
let a = 5; a |= 2; // 7 // 5: 00000000000000000000000000000101 // 2: 00000000000000000000000000000010 // ----------------------------------- // 7: 00000000000000000000000000000111
Specification |
---|
{{SpecName('ESDraft', '#sec-assignment-operators', 'Assignment operators')}} |
{{Compat("javascript.operators.bitwise_or_assignment")}}