Run details:
Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Mobile/15E148 Safari/604.1
Mobile Safari 14
iOS 14.6
Mobile
3 years ago
Test name Executions per second
Object.values(obj) 3141.3 Ops/sec
_.values(obj) 2971.2 Ops/sec
for...in 3749.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);