map은 callback 함수를 각각의 요소에 대해 한번씩 순서대로 불러 그 함수의 반환값으로 새로운 배열을 만듭니다.
arr.map(callback(currentValue[, index[, array]])[, thisArg]
callback : 새로운 배열 요소를 생성하는 함수.
currentValue : 처리할 현재요소
index : 처리할 현재 요소의 인덱스
array : map()을 호출한 배열.
thisArg : callback을 실행할 때 this로 사용되는 값.
let numbers = [1, 4, 9];
let roots = numbers.map(Math.sqrt);
// roots는 [1, 2, 3]
// numbers는 그대로 [1, 4, 9]
let numbers = [1, 4, 9];
let doubles = numbers.map(function(num) {
return num * 2;
doubles 는 이제 [2, 8, 18]
numbers는 그대로 [1, 4, 9]