Function product

  • Category

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

    Time complexity: O(1)

    Space complexity: O(1)

    Parameters

    • a: number

      First factor

    • b: number

      Second factor

    Returns number

    The product of a and b

    Reducers

    Example

    const array = [1, 2, 3];

    array.reduce(product); // 6
  • Category

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

    Time complexity: O(1)

    Space complexity: O(1)

    Parameters

    • a: bigint

      First factor

    • b: bigint

      Second factor

    Returns bigint

    The product of a and b

    Reducers

    Example

    const array = [1n, 2n, 3n];

    array.reduce(product); // 6n