@extremejs/utils - v1.0.0-beta.24
    Preparing search index...

    Function sumByProperty

    • Sums numeric properties selected by the same key or path on each element, starting at positive zero. Skips sparse array holes and leaves the array unchanged.

      Corresponds to Lodash's sumBy(values, path) property shorthand. This utility uses ExtremeJS get paths, so dotted paths traverse nested properties even when a matching literal key exists. Missing, null, or undefined values contribute zero. Lodash skips undefined and uses null as a value. If every lookup in a nonempty array yields undefined, Lodash returns undefined. Its sum starts at the first defined value, which can preserve negative zero.

      Type Parameters

      Parameters

      Returns number

      The sum, or zero for an empty array. A selected NaN propagates to the result.

      1.0.0

      sumByProperty([{ a: 1 }, { a: 2 }, { a: 3 }], "a"); // => 6