Options
All
  • Public
  • Public/Protected
  • All
Menu

Module array/findIndex

Index

References

Functions

References

Renames and re-exports findIndex

Functions

  • findIndex<T>(fn: ArrPred<T>, list: ArrayLike<T>): number
  • findIndex<T>(fn: ArrPred<T>): (list: ArrayLike<T>) => number
  • Returns the index of the first element of the list which matches the predicate, or -1 if no element matches.

    example
     var xs = [{a: 1}, {a: 2}, {a: 3}];
    findIndex(x => x.a === 2)(xs); //=> 1
    findIndex(x => x.a === 4)(xs); //=> -1

    Type parameters

    • T

    Parameters

    • fn: ArrPred<T>

      The predicate function used to determine if the element is the desired one.

    • list: ArrayLike<T>

    Returns number

    The index of the element found, or -1.

  • Returns the index of the first element of the list which matches the predicate, or -1 if no element matches.

    example
     var xs = [{a: 1}, {a: 2}, {a: 3}];
    findIndex(x => x.a === 2)(xs); //=> 1
    findIndex(x => x.a === 4)(xs); //=> -1

    Type parameters

    • T

    Parameters

    • fn: ArrPred<T>

      The predicate function used to determine if the element is the desired one.

    Returns (list: ArrayLike<T>) => number

    The index of the element found, or -1.

      • (list: ArrayLike<T>): number
      • Parameters

        • list: ArrayLike<T>

        Returns number

Generated using TypeDoc