Script Preparation code:
x
 
var obj = {
  'a': {
    id: 'a',
    num: 1
  },
  'b': {
    id: 'b',
    num: 1
  },
  'c': {
    id: 'c',
    num: 1
  },
  'd': {
    id: 'd',
    num: 1
  },
  'e': {
    id: 'e',
    num: 1
  },
  'f': {
    id: 'f',
    num: 1
  },
  'g': {
    id: 'g',
    num: 1
  },
};
var arr = [
  {
    id: 'a',
    num: 1
  },
  {
    id: 'b',
    num: 1
  },
  {
    id: 'c',
    num: 1
  },
  {
    id: 'd',
    num: 1
  },
  {
    id: 'e',
    num: 1
  },
  {
    id: 'f',
    num: 1
  },
  {
    id: 'g',
    num: 1
  },
];
Tests:
  • for-in

     
    for (var i=10000; i > 0; i--) {
      arr.forEach(i => {
        console.log(i.id === 'e')
      })
    }
  • Object.keys

     
    for (var i=10000; i > 0; i--) {
      Object.keys(obj).forEach(key => console.log(obj[key].id));
    }
  • Object.values

     
    for (var i=10000; i > 0; i--) {
      Object.values(obj).forEach(n => console.log(n.id));
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    for-in
    Object.keys
    Object.values

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 months ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Chrome 131 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
for-in 10.6 Ops/sec
Object.keys 10.3 Ops/sec
Object.values 10.4 Ops/sec