Sum Numbers
Calculates the total sum of a set of numbers or numeric strings.
sumNumbers
The sumNumbers function calculates the total sum of a set of numbers, accepting numeric values or numeric strings as rest parameters.
Function Signature
function sumNumbers(...numbers: Numeric[]): numberParameters
numbers(Numeric[]): A list of numbers (or numeric strings) to sum up.
Return Value
number: The sum of all the provided numbers. If no numbers are provided, it returns0.
Example Usage
playground.ts
Notes
- All input values are converted to numbers before summing.
- If no inputs are passed, the return value is
0.
Caution
It does not check for any invalid numeric inputs. For example, if you pass an invalid numeric string, it will return NaN.
Floating-Point Safety
For floating-point numbers, it's recommended to use safeAdd to avoid potential precision issues.
Aliases
The following aliases can be used for the sumNumbers function:
getSumOfNumberssumOfNumbers
Last updated: Tue, Jun 16, 2026 07:49:37PM (UTC)
