forEach()1 array.forEach() , map() forEach() callback 함수를 불러낸다 const numbers = [45,4,9,16,25]; //배열 생성 let text = ""; numbers.forEach(myFunction); function myFunction(value, index, array) { txt += value + " "; } 함수는 3개의 인자(argument)를 갖는다 -아이텝 값 -인텍스 값 -배열 하지만 위의 배열을 forEach()로 돌릴 때 값만 가지고 움직이기 때문에 아래와 같은 함수로 써도 괜찮다 function myFunction(value){ txt += value + " "; } map() https://www.freecodecamp.org/korean/news/javascript-map-meth.. 2022. 9. 28. 이전 1 다음