Typescript: Extend Array type with sum count avg min max Aggregates

In this article i’ll show you how to implement sum, count, avg, min and max aggregate functions that applies to all Array instances in typescript. First we will learn how to extend Array type: Extend Array prototype In javascript, you can extend an existing class by adding a new function to its prototype without modifying its source code. To add new function to Array type, you basically set the new function to Array....

September 3, 2023 · 4 min · 770 words · CodeGenos