Get an array of indexes of searchElement in an array. Strict equality (===) is used to compare elements.
searchElement
===
Time complexity: O(n)
Space complexity: O(n)
The array to search in
The element to search for
An array of indexes of searchElement in array
array
indexOfAll([1, 2, 1, 3, 1], 1); // [0, 2, 4] Copy
indexOfAll([1, 2, 1, 3, 1], 1); // [0, 2, 4]
findIndexAll if you want to use a predicate instead of strict equality
Array
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)