Array.prototype.findIndex()
Array.prototype.findIndex() is a JavaScript method in the Array category. Returns the index of the first element that satisfies the testing function. The syntax is array.findIndex(callbackFn, thisArg). A typical example: [1, 2, 3].findIndex(x => x > 1) // 1. Its time complexity is O(n), which matters when it runs over large inputs. The TypeScript signature is (predicate: (value: T, index: number, obj: T[]) => unknown, thisArg?: any): number. A close sibling is Array.prototype.map(), which creates a new array populated with the results of calling a provided function on every element. A close sibling is Array.prototype.filter(), which creates a new array with all elements that pass the test implemented by the provided function. A close sibling is Array.prototype.reduce(), which executes a reducer function on each element, resulting in a single output value. A close sibling is Array.prototype.forEach(), which executes a provided function once for each array element.