This method is like `min` except that it accepts `iteratee` which is invoked for each element in `array` to generate the criterion by which the value is ranked. The iteratee is invoked with one argument: (value).
const objects = [{ 'n': 1 }, { 'n': 2 }]
minBy(objects, ({ n }) => n)
// => { 'n': 1 }
Name | Type | Attribute | Description |
---|---|---|---|
array | The array to iterate over. | ||
iteratee | The iteratee invoked per element. |
*
{ "comment": "/**\r\n * This method is like `min` except that it accepts `iteratee` which is\r\n * invoked for each element in `array` to generate the criterion by which\r\n * the value is ranked. The iteratee is invoked with one argument: (value).\r\n *\r\n * @since 4.0.0\r\n * @category Math\r\n * @param {Array} array The array to iterate over.\r\n * @param {Function} iteratee The iteratee invoked per element.\r\n * @returns {*} Returns the minimum value.\r\n * @example\r\n *\r\n * const objects = [{ 'n': 1 }, { 'n': 2 }]\r\n *\r\n * minBy(objects, ({ n }) => n)\r\n * // => { 'n': 1 }\r\n */", "meta": { "range": [ 596, 1070 ], "filename": "minBy.js", "lineno": 20, "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo", "code": { "id": "astnode100006313", "name": "minBy", "type": "FunctionDeclaration", "paramnames": [ "array", "iteratee" ] }, "vars": { "result": "minBy~result", "index": "minBy~index", "length": "minBy~length", "computed": "minBy~computed", "value": "minBy~value", "current": "minBy~current" } }, "description": "This method is like `min` except that it accepts `iteratee` which is\rinvoked for each element in `array` to generate the criterion by which\rthe value is ranked. The iteratee is invoked with one argument: (value).", "since": "4.0.0", "tags": [ { "originalTitle": "category", "title": "category", "text": "Math", "value": "Math" } ], "params": [ { "type": { "names": [ "Array" ] }, "description": "The array to iterate over.", "name": "array" }, { "type": { "names": [ "function" ] }, "description": "The iteratee invoked per element.", "name": "iteratee" } ], "returns": [ { "type": { "names": [ "*" ] }, "description": "Returns the minimum value." } ], "examples": [ "const objects = [{ 'n': 1 }, { 'n': 2 }]\r\rminBy(objects, ({ n }) => n)\r// => { 'n': 1 }" ], "name": "minBy", "longname": "minBy", "kind": "function", "scope": "global", "___id": "T000002R000588", "___s": true, "filepath": "minBy.js" }