Aggregating
Last updated
Reduce an array to a single value. Numeric aggregates ignore non-numeric elements.
.sum() → numberAdds the numeric elements.
log [1, 2, 3, 4, 5].sum() // 15
log [1, "two", 3, null].sum() // 4.product() → numberMultiplies the numeric elements.
log [1, 2, 3, 4].product() // 24.average() → numberThe mean of the elements.
log [1, 2, 3].average() // 2.max() → number / .min() → numberThe largest / smallest element.
arr = [3, 1, 4, 1, 5, 9, 2, 6]
log arr.max() // 9
log arr.min() // 1.join(sep) → stringJoins the elements into a string separated by sep.
Last updated
log [1, 2, 3].join("-") // "1-2-3"