forEach vs loop

Benchmark created on


Setup

var arr = [];
    for(var i = 0; i < 100000; i++) arr[i]=i;

Test runner

Ready to run.

Testing in
TestOps/sec
forEach
arr.forEach(function(v){v;});
ready
loop
for(var i = 0, l = arr.length; i < l; i++){arr[i];}
ready

Revisions

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