Skip to Content

sumBy()

Sums the value of a specific numeric property across all objects in an array.

Returns 0 if the result is not a number (guards against NaN from missing properties).

Kind: global function
Returns: number - The total sum, or 0 if the result is not a valid number.

ParamTypeDescription
objectsArray.<Object>The array of objects.
sumByPropertystringDot-notation path to the numeric property.

Example

ARM.sumBy(orderItems, 'attributes.quantity')
Last updated on