The array of numbers.
The sum of all numbers in the array.
If the array length is 0.
sum([1, 2, 3]); // Returns 6
Computes the sum of a bigint array.
The array of bigints.
The sum of all bigints in the array.
If the array length is 0.
sum([1n, 2n, 3n]); // Returns 6n
Computes the sum of an array of type T using the provided numerical implementation.
The type of elements in the array.
The array of elements.
Optional
numerical: Numerical<T>(Optional) An instance of the Numerical interface for type T. If not provided, a default numerical implementation will be used based on the type of the array elements. If the array is neither number[] nor bigint[], a numerical instance must be provided.
The sum of all elements in the array.
If the array length is 0.
If the array type is not number[] or bigint[] and no numerical implementation is provided.
sum([1, 2, 3]); // Returns 6
sum([1n, 2n, 3n]); // Returns 6n
sum([1, 2, 3], new NumericalNumber()); // Returns 6 using NumericalNumber implementation
sum([1n, 2n, 3n], new NumericalBigInt()); // Returns 6n using NumericalBigInt implementation
Generated using TypeDoc
Computes the sum of a number array.