ichigyou
    Preparing search index...

    Function findIndex

    • Finds the index of a given element in an array.

      Type Parameters

      • T

      Parameters

      • arr: T[]

        The array in which to find the element.

      • element: T

        The element to find.

      Returns number

      The index of the element in the array, or -1 if the element is not found.

      const arr = [1, 2, 3, 4, 5];
      const element = 3;
      const index = findIndex(arr, element);
      console.log(index); // 2