Array.forEach vs native for (v6)

Revision 6 of this benchmark created 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] = i;
    }

Test runner

Ready to run.

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

Revisions

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