sum
The sum() method adds all the numeric values of an immutable array and returns the total sum as a number.
Interactive example
Syntax
typescript
function sum<
GenericInput extends readonly number[]
>(
input: GenericInput
): numberParameters
input: Array of numbers to add.
Return value
The total sum of all the elements of the array. When the input is a tuple, TypeScript can infer a literal sum if the compiler is able to compute it.
