Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:136.0) Gecko/20100101 Firefox/136.0
Firefox 136
Mac OS X 10.15
Desktop
one month ago
Test name Executions per second
sum 12114563.0 Ops/sec
reduce 7794321.5 Ops/sec
HTML Preparation code:
AخA
 
1
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script>
Script Preparation code:
 
var arr = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
Tests:
  • sum

     
    _.sum(arr)
  • reduce

     
    arr.reduce((a, c) => a + c, 0)