forEach (v7)

Revision 7 of this benchmark created by Marshall on


Description

Array.forEach vs underscore.forEach vs lodash.forEach vs for in vs for of

Preparation HTML

<script src="http://underscorejs.org/underscore-min.js"></script>

<script src="https://raw.githubusercontent.com/lodash/lodash/4.6.1/dist/lodash.core.js"></script>

Setup

var arr = [];
    
    for (var i = 0; i < 100000; i++) {
      arr.push(i)
    }

Test runner

Ready to run.

Testing in
TestOps/sec
underscore.forEach
_(arr).forEach(function(x) {
  x += 1;
});
ready
Array.forEach
arr.forEach(function(x) {
  x += 1;
});
ready
for in
for (x in arr) {
  x += 1;
}
ready
for of
for (x of arr) {
  x += 1;
}
ready
lodash.forEach
lodash.forEach(arr, function(x) {
  x += 1;
});
ready

Revisions

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