See the Pen find(), findIndex() by nilgi (@nilgi) on CodePen.
• find(): 요소 찾기
let gf1 = no1.find(myFunction);
function myFunction(value, index, array) {
return value > 24;
}
// 조건에 맞는 첫 번째 요소를 표시
• findIndex(): 요소를 찾고 그 요소의 위치 표시
document.getElementById("gr_fi").innerHTML = no2.findIndex(myFunction);
function myFunction(value, index, array) {
return value > 24;
}
// 조건에 맞는 첫 번째 요소의 위치 표시