• Category

    Calculate the bitwise XOR of 2 numbers. Meant to be used with Array.prototype.reduce.

    Time complexity: O(1)

    Space complexity: O(1)

    Parameters

    • a: number

      First operand

    • b: number

      Second operand

    Returns number

    The bitwise XOR of a and b

    Reducers

    Example

    const array = [5, 3];

    array.reduce(Bitwise.xor); // 6
  • Category

    Calculate the bitwise XOR of 2 bigints. Meant to be used with Array.prototype.reduce.

    Time complexity: O(1)

    Space complexity: O(1)

    Parameters

    • a: bigint

      First operand

    • b: bigint

      Second operand

    Returns bigint

    The bitwise XOR of a and b

    Reducers

    Example

    const array = [5n, 3n];

    array.reduce(Bitwise.xor); // 6n