(JS) map() (2019/10/23)(보충필요!!)
개발노트/Javascript2019. 10. 23. 17:17(JS) map() (2019/10/23)(보충필요!!)

개념 배열 내의 모든 요소 각각에 대해서 map()의 return값을 적용시켜 새로운 함수로 만든다. foreach()처럼 배열의 length만큼 반복시켜 배열 값들에게 return값을 적용. Array.map(callbackFunction(elementValue, index, array) 1. elementValue 배열 내에서 현재 값 2. index 배열 내에서 현재 인덱스 번호 3. array 배열 length만큼 배열을 출력한다. 사용방법 let mapping = [1, 2, 3, 4, 5]; let remap = mapping.map(function(element){ return element * 10; }) console.log(remap); // [10, 20, 30, 40, 50] 출력 ..

image