@jonahsnider/util

    Function indexOfAll

    • Get an array of indexes of searchElement in an array. Strict equality (===) is used to compare elements.

      Time complexity: O(n)

      Space complexity: O(n)

      Type Parameters

      • T

      Parameters

      • array: ArrayLike<T>

        The array to search in

      • searchElement: T

        The element to search for

      Returns number[]

      An array of indexes of searchElement in array

      indexOfAll([1, 2, 1, 3, 1], 1); // [0, 2, 4]
      

      findIndexAll if you want to use a predicate instead of strict equality

      Array

    MMNEPVFCICPMFPCPTTAAATR