> For the complete documentation index, see [llms.txt](https://lodash.shujuwajue.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lodash.shujuwajue.com/array/takerightwhile.md).

# \_.takeRightWhile（数组截取）

**语法：**

```javascript
_.takeRightWhile(array, [predicate=_.identity])
```

**源代码链接：**[source](https://github.com/lodash/lodash/blob/4.17.10/lodash.js#L8247)

**npm包链接：**[npm package](https://www.npmjs.com/package/lodash.takerightwhile)

**描述：**

从`array`数组的最后一个元素开始提取元素，直到`predicate`返回假值。`predicate`会传入三个参数：*(value, index, array)*。

**开始版本：**&#x33;.0.0

**参数：**

* `array (Array)`: 要检索的数组。
* `[predicate=_.identity] (Array|Function|Object|string)`: 每次迭代调用的函数。

**返回值：**

* `(Array)`: 返回 array 数组的切片。

**例子：**

```javascript
var users = [
  { 'user': 'barney',  'active': true },
  { 'user': 'fred',    'active': false },
  { 'user': 'pebbles', 'active': false }
];

_.takeRightWhile(users, function(o) { return !o.active; });
// => objects for ['fred', 'pebbles']

// The `_.matches` iteratee shorthand.
_.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
// => objects for ['pebbles']

// The `_.matchesProperty` iteratee shorthand.
_.takeRightWhile(users, ['active', false]);
// => objects for ['fred', 'pebbles']

// The `_.property` iteratee shorthand.
_.takeRightWhile(users, 'active');
// => []
```
