Javascript ES6+ forEach, map, reduce 메소드
forEach, map, reduce 메소드 forEach Array.prototype.forEach(callback[, thisArg]) callback : function (currentValue[, index[, originalArray]]) currentValue : 현재값 index : 현재 인덱스 originalArray : 원본 배열 thisArg : this에 할당할 대상. 생략시 global객체 for문을 돌리는 것이랑 같은 개념이다. const a = [ 1, 2, 3 ] a.forEach(function (v, i, arr) { console.log(v, i, arr, this) }, [ 10, 11, 12 ]) //결과: //1 0 [1, 2, 3] [10, 11, 12] //2 1..
2020. 12. 8.