Home

function: findLastIndex


findLastIndex(array: Array, predicate: function, fromIndex: number): number

This method is like `findIndex` except that it iterates over elements of `collection` from right to left.

Example(s):

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

findLastIndex(users, ({ user }) => user == 'pebbles')
// => 2

Params:

Name Type Attribute Description
array The array to inspect.
predicate The function invoked per iteration.
fromIndex The index to search from.

Returns:

number

  {
    "comment": "/**\r\n * This method is like `findIndex` except that it iterates over elements\r\n * of `collection` from right to left.\r\n *\r\n * @since 2.0.0\r\n * @category Array\r\n * @param {Array} array The array to inspect.\r\n * @param {Function} predicate The function invoked per iteration.\r\n * @param {number} [fromIndex=array.length-1] The index to search from.\r\n * @returns {number} Returns the index of the found element, else `-1`.\r\n * @see find, findIndex, findKey, findLast, findLastKey\r\n * @example\r\n *\r\n * const users = [\r\n *   { 'user': 'barney',  'active': true },\r\n *   { 'user': 'fred',    'active': false },\r\n *   { 'user': 'pebbles', 'active': false }\r\n * ]\r\n *\r\n * findLastIndex(users, ({ user }) => user == 'pebbles')\r\n * // => 2\r\n */",
    "meta": {
        "range": [
            796,
            1170
        ],
        "filename": "findLastIndex.js",
        "lineno": 25,
        "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
        "code": {
            "id": "astnode100002449",
            "name": "findLastIndex",
            "type": "FunctionDeclaration",
            "paramnames": [
                "array",
                "predicate",
                "fromIndex"
            ]
        },
        "vars": {
            "length": "findLastIndex~length",
            "index": "findLastIndex~index"
        }
    },
    "description": "This method is like `findIndex` except that it iterates over elements\rof `collection` from right to left.",
    "since": "2.0.0",
    "tags": [
        {
            "originalTitle": "category",
            "title": "category",
            "text": "Array",
            "value": "Array"
        }
    ],
    "params": [
        {
            "type": {
                "names": [
                    "Array"
                ]
            },
            "description": "The array to inspect.",
            "name": "array"
        },
        {
            "type": {
                "names": [
                    "function"
                ]
            },
            "description": "The function invoked per iteration.",
            "name": "predicate"
        },
        {
            "type": {
                "names": [
                    "number"
                ]
            },
            "optional": true,
            "defaultvalue": "array.length-1",
            "description": "The index to search from.",
            "name": "fromIndex"
        }
    ],
    "returns": [
        {
            "type": {
                "names": [
                    "number"
                ]
            },
            "description": "Returns the index of the found element, else `-1`."
        }
    ],
    "see": [
        "find, findIndex, findKey, findLast, findLastKey"
    ],
    "examples": [
        "const users = [\r  { 'user': 'barney',  'active': true },\r  { 'user': 'fred',    'active': false },\r  { 'user': 'pebbles', 'active': false }\r]\r\rfindLastIndex(users, ({ user }) => user == 'pebbles')\r// => 2"
    ],
    "name": "findLastIndex",
    "longname": "findLastIndex",
    "kind": "function",
    "scope": "global",
    "___id": "T000002R000269",
    "___s": true,
    "filepath": "findLastIndex.js"
}