企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## findLastKey + [link](./findLastKey "Link to this entry.") + [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L10977 "View in source.") + [npm](https://www.npmjs.com/package/lodash.findlastkey "See the npm package.") ``` _.findLastKey(object, [predicate=_.identity]) ``` 这个方法类似 `_.findKey`。 不过它是反方向开始遍历的。 ### 参数 1. object (Object) 需要检索的对象 2. [predicate=_.identity] (Function|Object|string) 这个函数会处理每一个元素 ### 返回值 (string|undefined) 返回匹配的 key,否则返回 `undefined`。 ### 示例 ``` var users = { 'barney': { 'age': 36, 'active': true }, 'fred': { 'age': 40, 'active': false }, 'pebbles': { 'age': 1, 'active': true } }; _.findLastKey(users, function(o) { return o.age < 40; }); // => 返回 'pebbles', `_.findKey` 会返回 'barney' // 使用了 `_.matches` 的回调结果 _.findLastKey(users, { 'age': 36, 'active': true }); // => 'barney' // 使用了 `_.matchesProperty` 的回调结果 _.findLastKey(users, ['active', false]); // => 'fred' // 使用了 `_.property` 的回调结果 _.findLastKey(users, 'active'); // => 'pebbles' ```