Options
All
  • Public
  • Public/Protected
  • All
Menu

Module findLastIndex

Index

References

Functions Array

References

Renames and re-exports findLastIndex

Array Functions

  • findLastIndex(array: any, predicate?: any, fromIndex?: number): number
  • This method is like findIndex except that it iterates over elements of collection from right to left.

    since

    5.2.0

    example

    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

    Parameters

    • array: any

      The array to inspect.

    • Optional predicate: any

      The function invoked per iteration.

    • Optional fromIndex: number

      The index to search from.

    Returns number

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