Javascript examples for Array Operation:Array of Object
Looping through objects within an array, count total of integer values
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {// ww w. ja v a 2 s . co m var basket = [ { price: "25.00", id: "A" }, { price: "50.00", id: "B" } ] var total = basket.reduce( function( previousValue, currentValue ){ return previousValue += parseInt(currentValue.price) }, 0) document.write(total) }); </script> </head> <body> </body> </html>