javascipt : reduce

$scope.totalPrice = function () {
                        return $scope.addcartProduct.reduce(function (money, product) {
                            return money += (product.quantity * product.priceAfter);
                        }, 0);
                    }

这 reduce forEach 很类似。不错!不用开变量

原文地址:https://www.cnblogs.com/stooges/p/3952379.html