inArray vs "in object" (v3)

Revision 3 of this benchmark created on


Description

Testing jquery.inArray vs "in object"

Setup

array = [];
    object = {};
    elem = null;
    
    for(var i = 0;i < 1000;i++){
    array.push(elem = {});
    object[i] = elem;
    }
    
    first = array[0];
    last = array[999];

Test runner

Ready to run.

Testing in
TestOps/sec
far indexOf
window.i = array.indexOf(last);
ready
far object
window.v = object[999];
ready
near indexOf
window.i = array.indexOf(first);
ready
near object
window.v = object[0];
ready

Revisions

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