for vs array-foreach (v13)

Revision 13 of this benchmark created on


Setup

var array = Array(31).join('x').split('');
    
    function callback(value, index, object) {
      return value;
    }

Test runner

Ready to run.

Testing in
TestOps/sec
for-loop
var length = array.length;
for (var index = 0; index < length; index++) {
  callback(array[index], index, array);
}
ready
Array#forEach
for (var index in array) {
  callback(array[index], index, array);
}
ready

Revisions

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