Options
All
  • Public
  • Public/Protected
  • All
Menu

Module lastIndexOf

Index

Functions Array

Array Functions

  • lastIndexOf<T>(array: ArrayLike<T>, value: T, fromIndex: number): number
  • This method is like indexOf except that it iterates over elements of array from right to left.

    since

    5.6.0

    example
    lastIndexOf([1, 2, 1, 2], 2)
    // => 3

    // Search from the `fromIndex`.
    lastIndexOf([1, 2, 1, 2], 2, 2)
    // => 1

    Type parameters

    • T

    Parameters

    • array: ArrayLike<T>

      The array to inspect.

    • value: T

      The value to search for.

    • fromIndex: number

      The index to search from.

    Returns number

    Returns the index of the matched value, else -1.