Array.indexOf vs Object's "in operator (v2)

Revision 2 of this benchmark created on


Description

Testing if access through Array.indexOf or Object's in Operator is faster.

Setup

var arr = [
       'that',
       'is',
       'some',
       'nice',
       'test',
       'here',
    ]
    
    var obj = {
       'that' : null,
       'is' : null,
       'some' : null,
       'nice' : null,
       'test' : null,
       'here' : null
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Array - Find first element
arr.indexOf('that');
ready
Object - Find first element
'that' in obj;
ready
Array - Find last element
arr.indexOf('here');
ready
Object - Find last element
'here' in obj;
ready

Revisions

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