find
findIndex
flat
条件を満たす最初の要素のインデックスを返します。
arr.findIndex(callbackFn)
下記の値を入力するとサンプルに即時反映されます。
const
numbers
idx
console
const numbers = [10, 20, 30, 40]; const idx = numbers.findIndex((n) => n > 25); console.log(idx); // 2