Home

function: takeRightWhile


takeRightWhile(array: Array, predicate: function): Array

Creates a slice of `array` with elements taken from the end. Elements are taken until `predicate` returns falsey. The predicate is invoked with three arguments: (value, index, array).

Example(s):

const users = [
  { 'user': 'barney',  'active': false },
  { 'user': 'fred',    'active': true },
  { 'user': 'pebbles', 'active': true }
]

takeRightWhile(users, ({ active }) => active)
// => objects for ['fred', 'pebbles']

Params:

Name Type Attribute Description
array The array to query.
predicate The function invoked per iteration.

Returns:

Array

  {
    "comment": "/**\r\n * Creates a slice of `array` with elements taken from the end. Elements are\r\n * taken until `predicate` returns falsey. The predicate is invoked with\r\n * three arguments: (value, index, array).\r\n *\r\n * @since 3.0.0\r\n * @category Array\r\n * @param {Array} array The array to query.\r\n * @param {Function} predicate The function invoked per iteration.\r\n * @returns {Array} Returns the slice of `array`.\r\n * @example\r\n *\r\n * const users = [\r\n *   { 'user': 'barney',  'active': false },\r\n *   { 'user': 'fred',    'active': true },\r\n *   { 'user': 'pebbles', 'active': true }\r\n * ]\r\n *\r\n * takeRightWhile(users, ({ active }) => active)\r\n * // => objects for ['fred', 'pebbles']\r\n */",
    "meta": {
        "range": [
            737,
            883
        ],
        "filename": "takeRightWhile.js",
        "lineno": 24,
        "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
        "code": {
            "id": "astnode100009041",
            "name": "takeRightWhile",
            "type": "FunctionDeclaration",
            "paramnames": [
                "array",
                "predicate"
            ]
        }
    },
    "description": "Creates a slice of `array` with elements taken from the end. Elements are\rtaken until `predicate` returns falsey. The predicate is invoked with\rthree arguments: (value, index, array).",
    "since": "3.0.0",
    "tags": [
        {
            "originalTitle": "category",
            "title": "category",
            "text": "Array",
            "value": "Array"
        }
    ],
    "params": [
        {
            "type": {
                "names": [
                    "Array"
                ]
            },
            "description": "The array to query.",
            "name": "array"
        },
        {
            "type": {
                "names": [
                    "function"
                ]
            },
            "description": "The function invoked per iteration.",
            "name": "predicate"
        }
    ],
    "returns": [
        {
            "type": {
                "names": [
                    "Array"
                ]
            },
            "description": "Returns the slice of `array`."
        }
    ],
    "examples": [
        "const users = [\r  { 'user': 'barney',  'active': false },\r  { 'user': 'fred',    'active': true },\r  { 'user': 'pebbles', 'active': true }\r]\r\rtakeRightWhile(users, ({ active }) => active)\r// => objects for ['fred', 'pebbles']"
    ],
    "name": "takeRightWhile",
    "longname": "takeRightWhile",
    "kind": "function",
    "scope": "global",
    "___id": "T000002R000820",
    "___s": true,
    "filepath": "takeRightWhile.js"
}