Options
All
  • Public
  • Public/Protected
  • All
Menu

Module indexOf

Index

References

Functions Array

References

Renames and re-exports indexOf

Array Functions

  • indexOf<T>(array: ArrayLike<T>, value: T, fromIndex?: number): number
  • Gets the index at which the first occurrence of value is found in array using SameValueZero for equality comparisons. If fromIndex is negative, it's used as the offset from the end of array.

    since

    5.5.1

    example
    indexOf([1, 2, 1, 2], 2)
    // => 1

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

    Type parameters

    • T

    Parameters

    • array: ArrayLike<T>

      The array to inspect.

    • value: T

      The value to search for.

    • Optional fromIndex: number

      The index to search from.

    Returns number

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