닭발족발 나는 개발
Array.prototype.map()
FRONTEND/HTML+JavaScript 2022. 1. 11. 17:40

map() 메서드는 배열 내의 모든 요소 각각에 대해여 주어진 함수를 호출한 결과를 모아 새로운 배열을 반환합니다. const array1 = [1, 4, 9, 16] //pass a function to map const map1 = array1.map(x => x + 2) console.log(map1) //RESULT Array [2, 8, 18, 32] 구문 arr.map(callback(currentValue [, index [,array]]) [, thisArg] 매개변수 callback 새로운 배열 요소를 생성하는 함수. 다음 세가지 인수를 가진다. currentValue 처리할 현재 요소 index [Optional] 처리할 현재 요소의 인덱스 array [Optional] map()을 호..