For vs forEach (v4)

Revision 4 of this benchmark created on


Setup

var arr = new Array(10000);
    var res = new Array(10000);
    var len = arr.length;
    for(var i=0;i<len;++i)arr[i]=i;

Test runner

Ready to run.

Testing in
TestOps/sec
For
for (var i = 0; i < len; ++i)
{
    res[i] = arr[i] + 1;
}

console.log(res);
ready
forEach
arr.forEach(function(i) {
    res[i] = arr[i] + 1;
});

console.log(res);
ready

Revisions

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