forEach (v4)

Revision 4 of this benchmark created 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;
});
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.