Calculates the mean (average) of a specified numeric property in an array of objects.
The type of objects in the array.
The array of objects.
The key whose numeric values will be averaged.
The mean value for the specified key, or 0 if no valid numbers are found.
const data = [{ a: 2 }, { a: 4 }, { a: 6 }];meanBy(data, 'a'); // Returns 4 Copy
const data = [{ a: 2 }, { a: 4 }, { a: 6 }];meanBy(data, 'a'); // Returns 4
Calculates the mean (average) of a specified numeric property in an array of objects.