HTML Preparation code:
AخA
 
1
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js"></script>
Script Preparation code:
 
var arr = Array.from({ length: 10000 }).map((value, i) => i);
Tests:
  • lodash.foreach

     
    _.forEach(arr, function(e, i) {})
  • native for-of

     
    for (const e of arr) {}
  • native for-of + entries

     
    for (const [i, e] of arr.entries()) {}
  • native forEach

     
    arr.forEach(function(e, i) {})
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    lodash.foreach
    native for-of
    native for-of + entries
    native forEach

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36
Chrome 113 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
lodash.foreach 24194.7 Ops/sec
native for-of 170903.1 Ops/sec
native for-of + entries 41844.2 Ops/sec
native forEach 225724.6 Ops/sec