forEach (v2)

Revision 2 of this benchmark created by Marshall on


Description

Testing forEach vs for in

Preparation HTML

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

Setup

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

Test runner

Ready to run.

Testing in
TestOps/sec
forEach
_(arr).forEach(function(x) {
  x + 1;
}).value();
ready
for in
for (x in arr) {
  x + 1;
}
ready

Revisions

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