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 obj = Array.from({ length: 1000 }).map((value, i) => i).reduce((val, v) => { val[v] = v; return val; }, {})
Tests:
  • lodash.each

     
    _.each(obj, function(v, k) {
      console.log(v, k);
    });
  • lodash.forOwn

     
    _.forOwn(obj, function(v, k) {
      console.log(v, k);
    });
  • Object.keys().forEach

     
    Object.keys(obj).forEach(function (k) {
      let v = obj[k];
      console.log(v, k);
    });
  • for..in

     
    for (const k in obj) {
      if (obj.hasOwnProperty(k)) {
        let v = obj[k];
        console.log(v, k);
      }
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    lodash.each
    lodash.forOwn
    Object.keys().forEach
    for..in

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36
Chrome 110 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
lodash.each 134.2 Ops/sec
lodash.forOwn 130.8 Ops/sec
Object.keys().forEach 146.4 Ops/sec
for..in 154.0 Ops/sec