Array.forEach vs native for (v8)

Revision 8 of this benchmark created by Benjamin on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/mootools/1.3/mootools-yui-compressed.js"></script>

Setup

var values = [];
    for (var i=0; i<10000; i++) {
    values[i] = {'value':i};
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Array.forEach
Array.forEach(values, function (val, key) {});
ready
Native for
for (var i=0, l=values.length; i<l; i++) {}
ready
w/o caching values.length
for (var i=0; i<values.length; i++) {}
ready

Revisions

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