for vs array-foreach (v24)

Revision 24 of this benchmark created on


Preparation HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>

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
for (var index = 0, length = array.length; index < length; index++) {
  callback(array[index], index, array);
}
ready
Array#forEach
array.forEach(callback);
ready
_.each
_.each(array, callback);
ready

Revisions

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