I have a data structure similar to this ->
var prices = [
{currency: '$', value: 52},
{currency: '$', value: 139},
{currency: '$', value: 31},
{currency: '$', value: 5}
];
I want to know the highest price from that data. I know I can loop over the array and collect the data, but what would be the best way of doing it ?
We can do this pretty neat by using
Array.prototype.mapalongsideMath.max. Since.map()returns an Array, we can use that to invokeMath.maxbyFunction.prototype.apply. The result would look likeThe above statement equals
which would return the same result, we just created it programatically.