Iterating for-loop normal and undefined (v2)

Revision 2 of this benchmark created by Enzo on


Setup

for (var items=9999,arr=[],obj={}, i=0, every=0; i<items; ++i) {
    
        //if (every++ < 2){
        //if (every++ < 3){
        //if (every++ < 10){
        if (i>9000){
            arr[i]=i;
            obj[i]=i;
        }
        else every = 0;
    
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Array
for (i=0; i<items;i++) {
        if (arr[i] !== undefined)
                arr[i];
}
ready
Array for hasOwn
for (i=0; i<items;i++) {
        if (arr.hasOwnProperty(i))
                arr[i];
}
ready
Array for-in
for (i in arr) {
        if (arr[i] !== undefined)
                arr[i];
}
ready
forEach
arr.forEach(function(item, i) {
     item;
});
ready
Object
for (i in obj)
        obj[i];
ready

Revisions

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