Run details:
Mozilla/5.0 (X11; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0
Firefox 94
Linux
Desktop
3 years ago
Test name Executions per second
Object.values(obj) 22047.3 Ops/sec
_.values(obj) 13219.5 Ops/sec
for...in 10286.6 Ops/sec
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);