Native vs lodash foreach (v6)

Revision 6 of this benchmark created on


Preparation HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js"></script>
<script>var lodash = _.noConflict();</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js"></script>
<script>var underscore = _.noConflict();</script>

Setup

testArray = [];
    for(var i =0; i < 10000; i++) {
      testArray[i] = Math.random();
    }
    doStuff = function(value, index) {
      // do stuff
    };

Test runner

Ready to run.

Testing in
TestOps/sec
Native
testArray.forEach(doStuff);
ready
Lodash chaining
lodash(testArray).forEach(doStuff);
ready
Lodash
lodash.forEach(testArray, doStuff);
ready
Underscore
underscore.forEach(testArray, doStuff);
ready
Native For
for(var key in testArray) {
   doStuff(testArray[key]);
}
ready

Revisions

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