자바스크립트 맵 사용법1 Array.prototype.map() map() 메서드는 배열 내의 모든 요소 각각에 대하여 주어진 함수를 호출한 결과를 모아 새로운 배열을 반환한다. const array1 = [1, 4, 9, 16]; // Pass a function to map const map1 = array1.map((x) => x * 2); console.log(map1); // Expected output: Array [2, 8, 18, 32] arr.map(callback(currentValue[, index[, array]])[, thisArg]) callback: 새로운 배열 요소를 생성하는 함수. 다음 세 가지 인수를 가집니다. currentValue: 처리할 현재 요소. index (Optional): 처리할 현재 요소의 인덱스. array (Opti.. 2024. 4. 23. 이전 1 다음