🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## takeRightWhile + [link](./takeRightWhile "Link to this entry.") + [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L6728 "View in source.") + [npm](https://www.npmjs.com/package/lodash.takerightwhile "See the npm package.") ``` _.takeRightWhile(array, [predicate=_.identity]) ``` 从数组的最右边开始提取数组,直到 `predicate` 返回假值。`predicate` 会传入三个参数:(value, index, array)。 ### 参数 1. array (Array) 需要处理的数组 2. [predicate=_.identity] (Function|Object|string) 这个函数会处理每一个元素 ### 返回值 (Array) 返回提取的元素数组 ### 示例 ``` var users = [ { 'user': 'barney', 'active': true }, { 'user': 'fred', 'active': false }, { 'user': 'pebbles', 'active': false } ]; _.takeRightWhile(users, function(o) { return !o.active; }); // => 结果: ['fred', 'pebbles'] // 使用了 `_.matches` 的回调处理 _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); // => 结果: ['pebbles'] // 使用了 `_.matchesProperty` 的回调处理 _.takeRightWhile(users, ['active', false]); // => 结果: ['fred', 'pebbles'] // 使用了 `_.property` 的回调处理 _.takeRightWhile(users, 'active'); // => [] ```