Array.prototype
今回はArray..prototype.reduce()の利用例についてエントリーしたいと思います。 足し算 1から5を足す計算例(initialValueとして0をaccに渡す) const arr = [1,2,3,4,5] const initialValue = 0 const result = arr.reduce((acc,cur) => acc += cur,initia…
今回はArray(配列)に格納されているオブジェクトを特定のプロパティで抽出をArray.prototype.filter()を用いて行います サンプルデータ type ArrayObj = { id: number name: string category: 'a' | 'b' } const arrayObj = [ { id: 1, name: 'taro', catego…