Person Project
Object Array 최대 , 최소값 구하기
클라인STR
2019. 1. 22. 00:09
Json Object 에서 특정 key 값의 최대, 최소 값 구하기
_.minBy(array, [iteratee=_.identity])
_.maxBy(array, [iteratee=_.identity])
var objects = [{ 'n': 1 }, { 'n': 2 }];_.maxBy(objects, function(o) { return o.n; });// => { 'n': 2 }// The `_.property` iteratee shorthand._.maxBy(objects, 'n');// => { 'n': 2 }
var objects = [{ 'n': 1 }, { 'n': 2 }];_.minBy(objects, function(o) { return o.n; });// => { 'n': 1 }// The `_.property` iteratee shorthand._.minBy(objects, 'n');// => { 'n': 1 }
참고 https://stackoverflow.com/questions/33351934/get-the-min-and-max-from-array-of-objects-with-underscore-js
https://lodash.com/docs/4.17.11#minBy
https://lodash.com/docs/4.17.11#maxBy