for vs array-foreach (v10)

Revision 10 of this benchmark created on


Setup

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

Test runner

Ready to run.

Testing in
TestOps/sec
for-loop
for (var index = 0, length = array.length; 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.