compare getting element by key vs getting by value

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
find
var officers1 = [
  { id: '20', name: 'Captain Piett' },
  { id: '24', name: 'General Veers' },
  { id: '56', name: 'Admiral Ozzel' },
  { id: '88', name: 'Commander Jerjerrod' }
];

let res1 = officers1.find(officer => officer.id === '56');
ready
get by key
var officers2 = {
  '20': { id: 20, name: 'Captain Piett' },
  '24': { id: 24, name: 'General Veers' },
  '56': { id: 56, name: 'Admiral Ozzel' },
  '88': { id: 88, name: 'Commander Jerjerrod' }
};

let res2 = officers2['56'];
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.