findIndex배열
조건을 만족하는 첫 번째 요소의 인덱스를 반환합니다.
문법
arr.findIndex(callbackFn)예제
아래 값을 입력하면 예제에 즉시 반영됩니다.
const→numbers→idx→findIndex→console→const numbers = [10, 20, 30, 40];
const idx = numbers.findIndex((n) => n > 25);
console.log(idx); // 2