Category
Get an array of all indexes of elements in an array that passed a given predicate.
Time complexity: O(n)
Space complexity: O(n)
The array to search in
The function to call for each element to decide whether it should be included in the result
An array of indexes of elements that passed predicate in array
predicate
array
findIndexAll([1, 2, 1, 3, 1], (element) => element === 1); // [0, 2, 4] Copy
findIndexAll([1, 2, 1, 3, 1], (element) => element === 1); // [0, 2, 4]
indexOfAll if you want to find all elements equal to a given value
Array
Get an array of all indexes of elements in an array that passed a given predicate.
Time complexity: O(n)
Space complexity: O(n)