Options
All
  • Public
  • Public/Protected
  • All
Menu

Module sumBy

Index

References

Functions Math

References

Renames and re-exports __type

Math Functions

  • sumBy(array: any, iteratee: any): number
  • This method is like sum except that it accepts iteratee which is invoked for each element in array to generate the value to be summed. The iteratee is invoked with one argument: (value).

    since

    5.6.0

    example
    const objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]

    sumBy(objects, ({ n }) => n)
    // => 20

    Parameters

    • array: any

      The array to iterate over.

    • iteratee: any

      The iteratee invoked per element.

    Returns number

    Returns the sum.