HTML Preparation code:
x
 
1
2
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
 
var obj = {}
for (let i = 0; i < 1000; ++i) {
    obj[`a${i}`] = i;
}
var transform = (n) => n * n + 1;
Tests:
  • lodash mapValues

     
    const newObj = _.mapValues(obj, (v, k) => transform(v));
  • vanilla object.keys

     
    const newObj = {};
    Object.keys(obj).forEach((key) => {
      newObj[key] = transform(obj[key]);
    });
  • lodash reduce

     
    const newObj = _.reduce(obj, (acc, val, key) => {
      acc[key] = transform(val);
      return acc;
    })
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    lodash mapValues
    vanilla object.keys
    lodash reduce

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 7 days ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:137.0) Gecko/20100101 Firefox/137.0
Firefox 137 on Mac OS X 10.15
View result in a separate tab
Test name Executions per second
lodash mapValues 3643.5 Ops/sec
vanilla object.keys 5305.5 Ops/sec
lodash reduce 4381.2 Ops/sec