sum es-toolkit
Returns the sum of all elements in an array of numbers.
Usage
sum(nums)
Use sum when you want to calculate the total of numbers. It adds up all numbers in an array to compute the sum.
Empty arrays and real-world examples.
Calculation results can be used with other functions.
Parameters
numsreadonly number[]required
The array of numbers to sum.
Returns
Returns the sum of all numbers in the array. Returns 0 for empty arrays.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.