<script type="text/javascript"> var nums = [1,2,3,4,5]; //计算数组的总和 var sum = nums.reduce(function(prev,cur,index,array){ return prev + cur }) alert(sum); //15 </script>
标签:type 计算 alert func asc blog script class reduce
<script type="text/javascript"> var nums = [1,2,3,4,5]; //计算数组的总和 var sum = nums.reduce(function(prev,cur,index,array){ return prev + cur }) alert(sum); //15 </script>
标签:type 计算 alert func asc blog script class reduce
原文地址:https://www.cnblogs.com/qqing/p/8455690.html