1 | initial version |
You can pass an optional second parameter to the findIndex
method, which represents the starting index from where the method should begin the search.
For example:
const array = [1, 2, 3, 4, 5, 6, 7, 8, 9];
const index = array.findIndex((element) => element > 5, 3);
console.log(index); // Output: 5
In the above example, findIndex
will start searching for an element that satisfies the provided condition starting from index 3
. It will return the index of the first element that satisfies the condition, which is 5
in this case.