foreach()1 [Javascript 기초] forEach(), map() 메소드 1. forEach() 메소드 forEach() 메소드는 배열의 요소를 반복하여 함수를 호출하며, 배열에서 루프를 돌 때 사용합니다. forEach() 메소드는 ES5 문법이며, 반복 처리가 가능하고 DOM 반복이 가능한 유사배열입니다. forEach() 메소드의 문법은 다음과 같습니다. colors.forEach((currentValue, index, arr)); currentValue: 배열의 값 index: 현재 항목의 인덱스(선택사항) arr: 현재 항목의 배열(선택사항) const colors = ["black", "red", "blue"]; colors.forEach((currentValue, index, arr)=>{ console.log(currentValue); // 배열값 console.. 2023. 5. 9. 이전 1 다음