reduce()とは Array.prototype.reduce() 配列からひとつの値を求めるときに使われる。 いろんなこと出来そう、便利そう、面白そう、、、と思ったので、理解を深めるためにメモに残す。 構文 accumulator(前回の値) currentValue(現在の値) currentIndex(現在currentとして処理されている要素のindex) array(現在操作されている配列) initialValueは第2引数で初期値がはいる。 const result = array.reduce((accumulator, currentValue, currentIndex, array) => { return accumulator }, initialValue) const array = [0, 1, 2, 3] const initialValue = 0