Explain the purpose of the | (bitwise OR) operator in JavaScript.

In JavaScript, the `|` operator is the bitwise OR (bitwise inclusive OR) operator. It performs a bitwise OR operation on the individual bits of two integers. The result is a new integer whose bits are set to 1 where at least one of the corresponding bits in the operands is set to 1.

Here's a basic example of the bitwise OR operator in action:

let num1 = 5;  // Binary: 0101
let num2 = 3;  // Binary: 0011

let result = num1 | num2;  // Bitwise OR

console.log(result);  // Outputs: 7 (Binary: 0111)


Explanation:
- `num1` in binary is `0101`.
- `num2` in binary is `0011`.
- The bitwise OR operation compares each pair of corresponding bits. If at least one of the bits is `1`, the result has a `1` in that position; otherwise, it has a `0`.
- In this example, the result is `0111` in binary, which is `7` in decimal.

The bitwise OR operator is often used in scenarios where specific bits in an integer need to be set to `1` based on the bits of the operands.

Here's an example of using the bitwise OR operator to combine or set specific bits:


// Setting the third and fourth bits to 1
let flags = 0b0010;
flags = flags | 0b1100;

console.log(flags.toString(2));  // Outputs: 1110 (Binary)
console.log(flags);               // Outputs: 14 (Decimal)


In this example, the bitwise OR operator is used to set the third and fourth bits to `1` in the `flags` variable. The result is `1110` in binary, which is `14` in decimal.