HTML Preparation code:
AخA
 
1
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.core.js"></script>
Script Preparation code:
 
function extractValues(obj) {
   const t = [];
   for(var key in obj) { t.push(obj[key]); }
   return t;
}
Tests:
  • Object.values(obj)

    x
     
    var i;
    var a = {};
    for (i = 0; i < 1000; i++) {
      a[i + ""] = i + "text";
    }
    Object.values(a);
  • _.values(obj)

     
    var i;
    var a = {};
    for (i = 0; i < 1000; i++) {
      a[i + ""] = i + "text";
    }
    _.values(a);
  • for...in

     
    var i;
    var a = {};
    for (i = 0; i < 1000; i++) {
      a[i + ""] = i + "text";
    }
    extractValues(a);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Object.values(obj)
    _.values(obj)
    for...in

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.183
Chrome 115 on Windows
View result in a separate tab
Test name Executions per second
Object.values(obj) 25393.9 Ops/sec
_.values(obj) 18673.3 Ops/sec
for...in 16724.4 Ops/sec