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 AND) operator performs a logical AND operation on each pair of corresponding bits of its numeric operands. When applied to standard JavaScript Number values, it evaluates the operands as 32-bit signed integers. When applied to BigInt values, it operates on arbitrary-precision integers without size truncation. It returns a 1 in each bit position where both operands have a 1; otherwise, it returns 0.
Execution Mechanics
When the& operator is invoked, the JavaScript engine evaluates the operands based on their types using the following sequence:
- Type Validation and Coercion:
- If both operands are
BigIntvalues, they bypass 32-bit conversion and are evaluated as arbitrary-precision integers. - If the operands are a mix of
BigIntandNumber, the engine throws aTypeError. - If either operand is a
Symbol, the engine throws aTypeError. - For other types, the engine implicitly coerces the operands to standard
Numbervalues. Strings and Booleans are parsed to their numeric equivalents. Values that resolve toNaN(e.g.,undefined, unparseable strings) ornullultimately evaluate to0during integer conversion.
- If both operands are
- Bitwise Alignment and Evaluation:
- For
Numberoperands: The engine applies the internalToInt32abstract operation. Fractional components of floating-point numbers are truncated, and the values are converted to 32-bit signed integers in two’s complement format. - For
BigIntoperands: The engine aligns the arbitrary-precision binary sequences. Conceptually, the shorter sequence is sign-extended (padded with its sign bit) to match the length of the longer sequence. - The engine evaluates the aligned sequences bit-by-bit using the following truth table:
| Bit A | Bit B | Result (
A & B) | | :---: | :---: | :---: | | 0 | 0 | 0 | | 0 | 1 | 0 | | 1 | 0 | 0 | | 1 | 1 | 1 |
- For
- Return:
- For
Numberoperands, the resulting 32-bit binary sequence is converted back into a standard JavaScriptNumber(IEEE 754 double-precision 64-bit float) and returned. - For
BigIntoperands, the resulting binary sequence is returned as a newBigInt.
- For
Syntax and Evaluation Examples
Standard Integer EvaluationMaster JavaScript with Deep Grasping Methodology!Learn More





