Function findLastIndex

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

    Parameters

    • array: any

      The array to inspect.

    • Optionalpredicate: any

      The function invoked per iteration.

    • OptionalfromIndex: number

      The index to search from.

    Returns number

    Returns the index of the found element, else -1.

    5.2.0


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

    findLastIndex(users, function(o) { return o.user == 'pebbles'; });
    // => 2

    // The `matches` iteratee shorthand.
    findLastIndex(users, { 'user': 'barney', 'active': true });
    // => 0

    // The `matchesProperty` iteratee shorthand.
    findLastIndex(users, ['active', false]);
    // => 2

    // The `property` iteratee shorthand.
    findLastIndex(users, 'active');
    // => 0