HTML Preparation code:
x
 
1
2
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js'></script>
Script Preparation code:
 
var data = Object.fromEntries(Array.from({
    length: 10000
}, (i) => ['key_' + i, i]));
Tests:
  • for of Object.keys

     
    const output = {}
    for(const key of Object.keys(data)) {
      const newKey = _.camelCase(key)
      output[newKey] = data[key]
    }
  • Object.fromEntries with keys

     
    Object.fromEntries(Object.keys(data).map((key) => [_.camelCase(key), data[key]]))
  • Object.fromEntries with entries

     
    Object.fromEntries(Object.entries(data).map((entry) => [_.camelCase(entry[0]), entry[1]]))
  • Object.fromEntries with entries - destruction entry

     
    Object.fromEntries(Object.entries(data).map(([key, value]) => [_.camelCase(key), value]))
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    for of Object.keys
    Object.fromEntries with keys
    Object.fromEntries with entries
    Object.fromEntries with entries - destruction entry

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 20 days ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Chrome 133 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
for of Object.keys 3264554.0 Ops/sec
Object.fromEntries with keys 2694602.8 Ops/sec
Object.fromEntries with entries 2668345.0 Ops/sec
Object.fromEntries with entries - destruction entry 2622282.2 Ops/sec