Use Compound Bitwise OR Assignment |= in JavaScript

Description

The following code shows how to use Compound Bitwise OR Assignment |=.

Example


<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
<!--from w  ww .  j a va 2s .c om-->
// 2 = 00000000000000000000000000000011
// 5 = 00000000000000000000000000000101
// 7 = 00000000000000000000000000000111

var x = 2;
x |= 5;
document.write("x = ",x);
</script>
</body>
</html>

Click to view the demo

The code above generates the following result.

Use Compound Bitwise OR Assignment |= in JavaScript