for vs array-foreach (v3)

Revision 3 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 index = 0, length = array.length;

for (index ;index < length; index++) {
  callback(array[index], index, array);
}
ready
Array#forEach
array.forEach(callback);
ready

Revisions

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