반응형
reduce(callbackFn, initialValue)
  • initiallValue없으면? If initialValue is not specified, previousValue is initialized to the first value in the array, and currentValue is initialized to the second value in the array.
  • initialValue없고 대상array내 값이 1개뿐이라면?
    • 뭘해도 [A] -> reduce(...) -> A 형태로 결과가 나옴, 즉 1개 있던 value가 array를 빠져나오게됨

 

reduce((previousValue, currentValue, currentIndex, array) => { /* … */ }, initialValue)
  • previousValue: accumulated values until now
반응형

+ Recent posts