이 findIndex()메서드는 제공된 테스트 기능을 충족하는 배열의 첫 번째 요소 인덱스를 반환합니다. 테스트 기능을 만족하는 요소가 없으면 -1이 반환
매개변수
callbackFn
배열의 각 요소에 대해 실행할 함수입니다. 일치하는 요소가 발견되었음을 나타내기 위해 true 값을 반환하고 그렇지 않으면 falsy 값을 반환해야 합니다 . 이 함수는 다음 인수로 호출됩니다.
element
배열에서 처리 중인 현재 요소입니다.
index
배열에서 처리 중인 현재 요소의 인덱스입니다.
array
배열이 findIndex()호출되었습니다.
thisArg 선택 과목
this를 실행할 때 사용할 값입니다 callbackFn. 반복 방법을 참조하십시오 .
반환 값
테스트를 통과하는 배열의 첫 번째 요소 인덱스입니다. 그렇지 않으면 -1.
Description
∙ The findIndex() method executes a function for each array element.
∙ The findIndex() method returns the index (position) of the first element that passes a test.
∙ The findIndex() method returns -1 if no match is found.
∙ The findIndex() method does not execute the function for empty array elements.
∙ The findIndex() method does not change the original array.