Computes the mean of the values in iterable and accepts an optional key function which is invoked for each element to generate the values to be averaged.
iterable
key
Returns the mean value or NaN if no elements.
NaN
let objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]mean(objects, (o) => o.n)// 5
Optional
Generated using TypeDoc
Computes the mean of the values in
iterable
and accepts an optionalkey
function which is invoked for each element to generate the values to be averaged.Returns
Returns the mean value or
NaN
if no elements.Example