If you really have to use jQuery, you can do this:
var totalTaxes = 0; $.each(taxes, function () { totalTaxes += this.amount; });
Or you can use the ES5 reduce function in browsers that support it:
totalTaxes = taxes.reduce(function (sum, tax) { return sum + tax.amount; }, 0);
Or just use a for loop, as in @epascarello's answer ...
Ates goral
source share