for or forEach (v3)

Revision 3 of this benchmark created on


Preparation HTML

<script>
  function times(n){ return Array(n+1).join('0').split('0') }
  
  var arr = [], k = 64
  times(1e2).forEach(function(n){ arr.push(n); })
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
for loop
var n = 0
for (var i=0;i<arr.length;i++) {
    n += arr[i];
}
ready
looping with forEach
var n = 0
arr.forEach(function(item){ n += item; });
ready

Revisions

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