Finds the index of the first element that satisfies a predicate.
const letters = ['a', 'b', 'c'] as const;const indexOfB = Arr.findIndex(letters, (letter) => letter === 'b');const indexOfMissing = Arr.findIndex<string>((letter) => letter === 'z')( letters,);assert.isTrue(indexOfB === 1);assert.isTrue(indexOfMissing === -1); Copy
const letters = ['a', 'b', 'c'] as const;const indexOfB = Arr.findIndex(letters, (letter) => letter === 'b');const indexOfMissing = Arr.findIndex<string>((letter) => letter === 'z')( letters,);assert.isTrue(indexOfB === 1);assert.isTrue(indexOfMissing === -1);
Finds the index of the first element that satisfies a predicate.