TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
|= (bitwise OR assignment) operator performs a bitwise OR operation between the binary representations of its left and right operands, assigning the resulting value to the left operand.
Syntax
Mechanics
- Operand Conversion:
- For
numbertypes, TypeScript (following JavaScript semantics) implicitly truncates both operands into 32-bit signed integers represented in two’s complement format. - For
biginttypes, operands are not truncated to 32 bits and retain their arbitrary precision during the bitwise operation.
- For
- Bitwise Evaluation: The operator compares the operands bit by bit. If either the left bit or the right bit at a given position is
1, the corresponding bit in the result is set to1. It yields0only if both bits are0. - Assignment: The evaluated result is assigned back to the left operand. For
numbertypes, the 32-bit integer result is converted back into a standard IEEE 754 double-precision float before assignment.
Truth Table
| Bitx | Bit y | Result (x | y) |
| :---: | :---: | :---: |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
Code Visualization
TypeScript Type Constraints
TypeScript enforces strict type checking on bitwise operators to prevent unintended runtime coercion:- Valid Numeric Types: Operands must be of a valid numeric type (
number,bigint, or anenum). Attempting to use|=with strictly typed non-numeric types (such asstring,boolean, orobject) will trigger compiler errorTS2362(for the left-hand side) orTS2363(for the right-hand side), stating that the operand “must be of type ‘any’, ‘number’, ‘bigint’ or an enum type.” Variables explicitly typed asanywill bypass this check and will not throw an error. - Type Homogeneity: TypeScript requires both operands to be of the exact same type. You cannot mix
numberandbigintwithout explicit casting. Mixing incompatible but otherwise valid numeric types triggersTS2365.
Master TypeScript with Deep Grasping Methodology!Learn More





