Arrays in JavaScript/TypeScript also have these kind of methods. You can again filter with you condition and then use reduce aggregation function to sum the items.

Copyconst sum = receiptItems.filter(item => item.tax === '25.00')
                        .reduce((sum, current) => sum + current.total, 0);

item.tax === '25.00' - this part you must adjust with your logic

Answer from Suren Srapyan on Stack Overflow
๐ŸŒ
Expert Code Blog
expertcodeblog.wordpress.com โ€บ 2018 โ€บ 10 โ€บ 31 โ€บ typescript-sum-of-object-properties
TypeScript: sum of object properties within an array | Expert Code Blog
October 31, 2018 - let sum: number = 0; itemArray.forEach(a => sum += a.value); console.log(sum ); // expected output: 81 ... Like Loading... To avoid creating temporary array in object array case, use reduce directly:
Discussions

javascript - Better way to sum a property value in an array
Yes if it comes after the sum function is created. 2014-12-03T10:39:40.617Z+00:00 ... This can result in NaN, if the prop does not exist (undefined) in one of the objects in the array. More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to sum an array of objects with a condition in typescript
Hi I am doing addition of key value from objects of an array. I want to exclude the object from the addition if it has some conditions. Example: var arrItem = [{"id": 1, "value":100},{"id": 2, "value":300},{"id": 3, "value":400}]; //addition this.sum = arrItem.map((a:any) => a.value).reduc... More on stackoverflow.com
๐ŸŒ stackoverflow.com
To sum values of object array in TS/JS
Communities for your favorite technologies. Explore all Collectives ยท Ask questions, find answers and collaborate at work with Stack Overflow for Teams More on stackoverflow.com
๐ŸŒ stackoverflow.com
Sum values of objects in array
Assuming you already have a sum function for simple arrays of numbers, you can implement a function that will sum the totals of all keys over an array of objects in just two expressions. No loops, hardcoded property names, anonymous functions or if/else required. More on stackoverflow.com
๐ŸŒ stackoverflow.com
January 14, 2020
๐ŸŒ
Digital Craftsman
blog.digital-craftsman.de โ€บ sum-numbers-in-array-of-objects-with-typescript
Sum numbers in array of objects with Typescript
April 27, 2020 - get numberOfUnhandledHours() { return this.timeEntries .filter((timeEntry: TimeEntry) => !timeEntry.approvedAt && !timeEntry.rejectedAt) .reduce((sum: number, b: TimeEntry) => sum + b.numberOfHours, 0); }
๐ŸŒ
GitHub
gist.github.com โ€บ benwells โ€บ 0111163b3cccfad0804d994c70de7aa1
Using Array.reduce to sum a property in an array of objects ยท GitHub
items = [ { customer_id: 1, id: 1, sum: 123} { customer_id: 1, id: 2, sum: 321} { customer_id: 1, id: 3, sum: 213}, ] var total_sum = items.reduce(function(prev, cur) { return prev + cur.summ; }, 0); console.log(total_sum) -> `NaN` %(
๐ŸŒ
GitHub
gist.github.com โ€บ 4442775
TypeScript example: function Array prototype: sum ยท GitHub
TypeScript example: function Array prototype: sum. GitHub Gist: instantly share code, notes, and snippets.
Find elsewhere
๐ŸŒ
Java Guides
javaguides.net โ€บ 2023 โ€บ 09 โ€บ typescript-sum-elements-of-array.html
TypeScript: Sum Elements of an Array
September 9, 2023 - In this guide, we'll design a TypeScript function that sums up all the numbers in an array.
๐ŸŒ
CoreUI
coreui.io โ€บ answers โ€บ how-to-sum-an-array-of-numbers-in-javascript
How to sum an array of numbers in JavaScript ยท CoreUI
September 29, 2025 - The initial value 0 ensures the function works correctly with empty arrays and provides a starting point for the accumulation. Each iteration adds the current number to the running total. The method returns a single value (the sum) rather than a new array, making it perfect for aggregation operations like summing.
๐ŸŒ
Webdevtutor
webdevtutor.net โ€บ blog โ€บ typescript-sum-values-in-object-array
Sums of Values in Object Array with TypeScript
We use the reduce() method to iterate over the array of objects. For each object, we add its totalQuantity property value to the accumulator using the binary operator +. Finally, we return the accumulated sum as the result. These examples demonstrate how you can use TypeScript's built-in methods ...
๐ŸŒ
Python Guides
pythonguides.com โ€บ sum-of-an-array-in-typescript
How To Calculate The Sum Of An Array In TypeScript?
January 24, 2025 - The callback function is executed for each element in the array, and the result is accumulated in the sum variable. The second argument to reduce() is the initial value of the accumulator, which is set to 0 in this case. ... In the examples above, we assumed that the array contains only numbers.
๐ŸŒ
Code Genos
codegenos.github.io โ€บ posts โ€บ typescript: extend array type with sum count avg min max aggregates
Typescript: Extend Array type with sum count avg min max Aggregates
September 3, 2023 - Since sum function only supports number we make generic type <T extends number>. To support arrays with more complex objects you can add map function mapFn: (v: T) => number. Then you can use sum function like: arr.sum(x => x.price).
๐ŸŒ
Blogger
bestwaytocode.blogspot.com โ€บ 2017 โ€บ 06 โ€บ typescript-foreach-sum-field-in-items.html
TypeScript: ForEach Sum Field in Items of an Array ~ Best Way to Code
June 29, 2017 - public getTotalWeight(): number { var total = 0; if (this.items != null && this.items.length > 0) { this.items.forEa...
๐ŸŒ
xjavascript
xjavascript.com โ€บ blog โ€บ typescript-sum-array
Mastering Array Summation in TypeScript โ€” xjavascript.com
An array is a collection of elements, and to find the sum, we need to iterate through each element and add it to a running total. In TypeScript, we need to consider the data types of the array elements to ensure type safety.
๐ŸŒ
Bobby Hadz
bobbyhadz.com โ€บ blog โ€บ javascript-get-sum-of-array-object-values
How to Sum a Property in an Array of Objects in JavaScript | bobbyhadz
March 2, 2024 - Use the reduce() method to iterate over the array. On each iteration increment the sum with the specific value. The result will contain the sum of the values for the specific property.
๐ŸŒ
A2-g
a2-g.com โ€บ hixjemo โ€บ typescript-sum-values-in-array-of-objects.html
Typescript sum values in array of objects
Using Array. TypeScript, like JavaScript, allows you to work with arrays of values. Itโ€™s basically a group of related methods and properties that describe an object. length; i++){ sum += numbers[i] } console.